Session Ready
Exercise

Randomization

Randomization of subjects in an experiment helps spread any variability that exists naturally between subjects evenly across groups. For ToothGrowth, an example of effective randomization would be randomly assigning male and female guinea pigs into different experimental groups, ideally canceling out any existing differences that naturally exist between male and female guinea pigs.

In the experiment that yielded the ToothGrowth dataset, guinea pigs were randomized to receive Vitamin C either through orange juice or ascorbic acid, indicated in the dataset by the supp variable. It's natural to wonder if there is a difference in tooth length by supplement type - a question that a t-test can also answer!

Starting with this exercise, you should use t.test() and other modeling functions with formula notation:

t.test(outcome ~ explanatory_variable, data = dataset)

This can be read: "test outcome by explanatory_variable in my dataset." The default test for t.test() is a two-sided t-test.

You no longer have to explicitly declare dataset$outcome, because the data argument is specified.

Instructions
100 XP
  • Conduct the proper test to determine if there is a difference in tooth length based on supplement type, and save the results as an object ToothGrowth_ttest.
  • Load the broom package.
  • Tidy the ToothGrowth_ttest with tidy(). This will print the results to the console.