letters[20:25]
## [1] "t" "u" "v" "w" "x" "y"
(10+12)*(2+3)
## [1] 110
5^3-3^(2+1)
## [1] 98
#Create vectors
vec1=rep(11:15,3)
vec2=rep(11:15,c(3,3,3,3,3))
vec3=rep(11:15,c(2,3,4,6,0))
#Output vectors
vec1
## [1] 11 12 13 14 15 11 12 13 14 15 11 12 13 14 15
vec2
## [1] 11 11 11 12 12 12 13 13 13 14 14 14 15 15 15
vec3
## [1] 11 11 12 12 12 13 13 13 13 14 14 14 14 14 14
exer4=data.frame(vec1,vec2,vec3)
#Load and label
pedantic.prime=read.csv(file.choose())
#Min and max
min(pedantic.prime)
## [1] 39
max(pedantic.prime)
## [1] 105
#Sample size (2 ways)
nrow(pedantic.prime)
## [1] 24
length(pedantic.prime$diameter)
## [1] 24
#Extract observations 9-18
pedantic.prime$diameter[9:18]
## [1] 46 86 105 43 53 45 47 39 56 66
#Mean and median of our extracted observations
pedantic = pedantic.prime$diameter[9:18]
mean(pedantic)
## [1] 58.6
median(pedantic)
## [1] 50
#Mean and median of a random sample of pedantic
pedanran = sample(pedantic,10,replace=FALSE)
mean(pedanran)
## [1] 58.6
median(pedanran)
## [1] 50
#Mean and median of pedantic.prime (full 24 observations)
mean(pedantic.prime$diameter)
## [1] 59.25
median(pedantic.prime$diameter)
## [1] 57
They are similar. They should be similar since both pedanran and pedantic are microcosms of pedantic.prime.
#Standard deviation and standard error of pedantic.prime
sd(pedantic.prime$diameter)
## [1] 15.52628
sd(pedantic.prime$diameter)/sqrt(length(pedantic.prime$diameter))
## [1] 3.169288
Standard deviation = distance each measurement is from sample mean
Standard error = distance each sample mean is from population mean