Week 3
Question 1 (Preparation) [2 marks]
• Histogram
hist()
• Box plot
boxplot()
• Scatter plot
plot()
sd()
Question 2 [2 marks]
The following data represent the height increase (in cm) of 10 tomato plants after receiving organic fertilizer for 6 weeks: 12.4, 14.1, 13.8, 15.0, 14.6, 16.2, 13.9, 15.4, 14.8, 12.9
Load the data in a variable
tomato_heights <- c(12.4, 14.1, 13.8, 15.0, 14.6, 16.2, 13.9, 15.4, 14.8, 12.9)
’’’{r}
xbar=mean(tomato_heights)
xbar=14.31
’’’
Median=Center point
median(tomato_heights)
median=14.35
Question 3[2 marks]
The following is the R output from summarising the monthly rent (in NZD) paid by households in Hamilton.
Rent
Min. : 420
1st Qu. : 610
Median : 780
Mean : 825
3rd Qu. : 980
Max. : 1650
Range=Max-Min
Range=1650-420
Range=1230
Question 4 [4 marks]
IQR=3rd Qu-1st Qu
IQR=980-610
IQR=370
We will again work with the penguin dataset here. Load the dataset in R.
data2 = read.csv(“/penguins.csv”)
hist(penguins$body_mass, main = “Histogram of Penguins Body Mass”, xlab=“Penguins body mass”)
The most common weight is between 3500 and 4000. There are more penguins that have a mass above the mode than below the mode.
boxplot(penguins$body_mass, main=“Box Plot of Penguins Body Mass”, xlab=“Penguins Body Mass”, horizontal = TRUE)
I can see that the median is just more than 4000, the lower quartile is around 3000, and the upper quartile is between 4500 and 5000. The range from the upper quartile to the Maximum is larger than the range from the minimum to the lower quartile.