CommencerCommencer gratuitement

Comparing groups

In this exercise, you will compare distributions of data across groups.

The PlantGrowth dataset from the datasets package contains results from an experiment on yields. The dataset contains two variables:

  • group - indicates if the given result is from the control group or one of the two treatment groups,
  • weight - the dried weight of plants used to measure yields.

Recall that tapply() can be used to compute metrics across groups.

For example,

tapply(df$x, df$grp, FUN = median)

returns median of x across grp from the df data frame.

Your task is to calculate means and visualize five common statistics of the yields' weight. The graphical depiction will help you to compare the differences in the response variable across groups.

Cet exercice fait partie du cours

Practicing Statistics Interview Questions in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Calculate means across groups
tapply(___, PlantGrowth$group, FUN = ___)

# Graphically compare statistics across groups
___(___ ~ group, data = ___)
Modifier et exécuter le code