Question 1.

*The log of a positive number

*What is the default base for the log function? calculate the log of your previous number with a different base.

*The log of a negative number (explain the answer)

log(20,10)
## [1] 1.30103
log(20) 
## [1] 2.995732

Question 2.

*Create a vector of 15 standard normal random variables. Calculate its mean and SD.

*Change the mean to 10 and the SD to 2 and recalculate the vector of 15 random normal variables. Calculate its mean and SD.

*Why are the means and SD not exactly the same as the means and SDs spe cified in the function?

f<-rnorm(15, mean =0, sd = 1) 
mean(f) 
## [1] -0.03890449
sd(f) 
## [1] 0.7056753
f<-rnorm(15, mean =10, sd = 2) 
mean(f) 
## [1] 9.645831
sd(f) 
## [1] 1.230614

Question 3.

*Vector Operations

*The weights of 6 individuals in kg are 60, 72, 57, 90, 95, 72

*Their heights (in m) are 1.80, 1.85, 1.72, 1.90, 1.74, 1.91

*Enter these vectors into R

*Create a scatterplot of weight vs. height. Interpret the scatterplot. - Calculate the BMI for each individual (BMI = weight in kg divided by the square of the height in m)

*Calculate the mean for weight

*Subtract the mean from each value of weight

*Sum the result. Now you know why we square the deviations from the mea n to calculate a standard deviation!

weight <- c(60, 72, 57, 90, 95, 72)
weight
## [1] 60 72 57 90 95 72
height <- c(1.80, 1.85, 1.72, 1.90, 1.74, 1.91)
height
## [1] 1.80 1.85 1.72 1.90 1.74 1.91
mean(weight)
## [1] 74.33333
mean(height)
## [1] 1.82
plot(weight, height)