LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Practicing Statistics Interview Questions in R

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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

# Graphically compare statistics across groups
___(___ ~ group, data = ___)
Code bearbeiten und ausführen