3.1 Comparing Two Samples

The CO2 data.frame is a dataset built into R showing the results of an experiment on the cold tolerance of grass. Grass samples from two regions (Quebec and Mississippi) were grown in either a chilled or nonchilled environment, and their CO2 uptake rate was tested.


Load the CO2 dataset.

data("CO2")


View the CO2 dataset like a spreadsheet.

View(CO2)


Use ggplot2 to create a boxplot comparing the CO2 uptake between the two treatments of grass- "chilled" and "nonchilled"

ggplot(CO2, aes(x=Treatment, y=uptake)) + geom_boxplot()


Perform a t-test to test for a difference in CO2 uptake between the two treatments of grass- "chilled" and "nonchilled"

t.test(CO2$uptake ~ CO2$Treatment)


What is the p-value computed by this t-test?

0.003107


Based on this test, and using a p-value threshold of .05, was there a significant difference between the CO2 uptake of chilled grass and nonchilled grass?

true


Create a boxplot comparing the CO2 uptake between the two types of grass- "Quebec" and "Mississippi"

ggplot(CO2, aes(x=Type, y=uptake)) + geom_boxplot()


Perform a t-test to test for a difference in CO2 uptake between the two types of grass- "Quebec" and "Mississippi". Save it as a variable called tt.

tt = t.test(CO2$uptake ~ CO2$Type)


Extract the computed p-value from your tt variable.

tt$p.value


Extract the computed 95% confidence interval from your tt variable.

tt$p.value


What is the upper bound of the t-test's confidence interval?

16.479572


What is the lower bound of the t-test's confidence interval?

8.839475