Exercise 1 (2 pts)

letters[20:25]
## [1] "t" "u" "v" "w" "x" "y"

Exercise 2 (2)

Part i.

(10+12)*(2+3)
## [1] 110

Part ii.

5^3-3^(2+1)
## [1] 98

Exercise 3 (3)

#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

Exercise 4 (1)

exer4=data.frame(vec1,vec2,vec3)

Exercise 5 (21)

Part i. (1)

#Load and label
pedantic.prime=read.csv(file.choose())

Part ii. (2)

#Min and max
min(pedantic.prime)
## [1] 39
max(pedantic.prime)
## [1] 105

Part iii. (1)

#Sample size (2 ways)
nrow(pedantic.prime)
## [1] 24
length(pedantic.prime$diameter)
## [1] 24

Part iv. (1)

#Extract observations 9-18
pedantic.prime$diameter[9:18]
##  [1]  46  86 105  43  53  45  47  39  56  66

Part v. (2)

#Mean and median of our extracted observations
pedantic = pedantic.prime$diameter[9:18]
mean(pedantic)
## [1] 58.6
median(pedantic)
## [1] 50

Part vi. (2)

#Mean and median of a random sample of pedantic
pedanran = sample(pedantic,10,replace=FALSE)
mean(pedanran)
## [1] 58.6
median(pedanran)
## [1] 50

Part vii. (2)

#Mean and median of pedantic.prime (full 24 observations)
mean(pedantic.prime$diameter)
## [1] 59.25
median(pedantic.prime$diameter)
## [1] 57

Part viii. (5)

They are similar. They should be similar since both pedanran and pedantic are microcosms of pedantic.prime.

Part ix. (5)

#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