Get startedGet started for free

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.

This exercise is part of the course

Practicing Statistics Interview Questions in R

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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

# Graphically compare statistics across groups
___(___ ~ group, data = ___)
Edit and Run Code