Sys.setenv(LANG = "en")
setwd("C:\\Users\\Adminpc\\Documents\\ZAJECIA_2018_2019\\SEDA\\L_2\\R_code_2")
apple<-read.csv("Apple_data.csv",
header=T,
sep=",",
dec="." )
str(apple)
View(ap)
View(apple)
apple$change <- (apple$Close-apple$Open)/apple$Open
apple$rate.change <- 1+apple$change
mean(apple$rate.change)
prod(apple$rate.change)^(1/length(apple$rate.change))
library(psych)
geometric.mean(apple$rate.change)
apple$weights <- apple$Volume/sum(apple$Volume)
weighted.mean(apple$rate.change, apple$weights)
mean(apple$rate.change, trim=0.1)
winsor.mean(apple$rate.change, trim=0.1)
apple$rate.change2 <- apple$rate.change
apple$rate.change2[0:100] <- max(apple$rate.change)+0.5
mean(apple$rate.change2)
mean(apple$rate.change2, trim=0.1)
mean(apple$rate.change2, trim=0.2)
winsor.mean(apple$rate.change2, trim=0.1)
winsor.mean(apple$rate.change2, trim=0.2)
set.seed(123)
binom <- rbinom(1000, 10, 0.6)
mean(binom)
median(binom)
table(binom)
names(sort(-table(binom)))[1]
set.seed(123)
logx <- rlnorm(1000)
mean(logx)
median(logx)
pdf <- density(logx)
plot(pdf)
NLSY<-read.csv("NLSY_EDA_class.csv",
header=T,
sep=",",
dec="." )
View(NLSY)
str(NLSY)
aggregate(NLSY[,c(7)], list(NLSY$sex), mean)
aggregate(NLSY[,c(7)], list(NLSY$sex), median)
aggregate(NLSY[,c(7)], list(NLSY$race), mean)
aggregate(NLSY[,c(7)], list(NLSY$race), median)
aggregate(NLSY[,c(7)], list(NLSY$education), mean)
aggregate(NLSY[,c(7)], list(NLSY$education), median)
quantile(NLSY$wage, (0.25))
quantile(NLSY$wage, probs=c(0.25, 0.5, 0.75))
aggregate(NLSY[,c(7)], list(NLSY$sex), quantile, probs=c(0.25, 0.5, 0.75))
quantile(NLSY$wage, probs=c(0.1, 0.9))
aggregate(NLSY[,c(7)], list(NLSY$sex), quantile, probs=c(0.1, 0.9))
quantile(NLSY$wage, probs=c(0.01, 0.90, 0.99))
aggregate(NLSY[,c(7)], list(NLSY$sex), quantile, probs=c(0.01, 0.90, 0.99))
v <- c(28, 43, 32, 18, 7, 15, 22, 23, 29, 9, 11, 16) #define vector
sort(v) #sort values
quarter_n <- length(v)/4 #count how many observations in each quartile
n <- 2*quarter_n #count how many observations in interquartile
n
