ComeçarComece de graça

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.

Este exercício faz parte do curso

Experimental Design in R

Ver curso

Instruções do exercício

  • Conduct a t-test to determine if there is a difference in tooth length (len) based on supplement type (supp), 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Perform a t-test
___ <- t.test(___, data = ToothGrowth)

# Load broom
library(___)

# Tidy ToothGrowth_ttest
___
Editar e executar o código