View the CO2 dataset (seen in Quiz 3.1) like a spreadsheet.
View(CO2)
Use ggplot2 to create a scatter plot with the concentration of CO2 ("conc" in the data.frame) on the x-axis, and the plant's CO2 uptake ("uptake" in the data frame) on the y axis
ggplot(CO2, aes(x=conc, y=uptake)) + geom_point()
Perform a linear regression on the dataset, predicting uptake using CO2 concentration. Save it to a variable called "fit"
fit = lm(uptake ~ conc, data=CO2)
Display a summary of the linear fit
summary(fit)
What is the estimate of the slope of the uptake/conc linear relationship?
0.017731
What is the p-value of the uptake/conc linear relationship?
2.91e-06
You may have noticed in the plot that the concentration ~ uptake relationship is not perfectly linear. Try making another scatter plot, but this time put concentration (x-axis) on a log scale.
ggplot(CO2, aes(x=conc, y=uptake)) + geom_point() + scale_x_log10()
While the relationship is still not perfectly linear, it does look closer. Try performing another linear regression, only this time predict uptake based on "log(conc)" instead of "conc". Save it to the variable lfit.
lfit = lm(uptake ~ log(conc), data=CO2)
View a summary of the fit of uptake to log(conc).
summary(lfit)
Did the linear relationship become more significant when concentration was placed on a log scale, or less significant?
More significant