1. Learn
  2. /
  3. Courses
  4. /
  5. Helsinki Open Data Science

Connected

Exercise

Plot first, ask questions later

To begin, we shall ignore the repeated-measures structure of the data and assume that all the observations are independent of one another. Now if we simply ignore that the sets of 11 weights come from the same rat, we have a data set consisting of 176 weights, times, and group memberships that we see can easily be analyzed using multiple linear regression. To begin, we will plot the data, identifying the observations in each group but ignoring the longitudinal nature of the data.

We'll start with a simple plot and continue by adding some styling elements. Feel free to experiment!

Instructions

100 XP
  • Check the dimensions of RATSL
  • Draw the Weight against Time plot
  • Add line type aesthetics to differentiate the rat groups by assigning aes(linetype = Group) as an argument to geom_line()
  • Add x-axis label and breaks by adding scale_x_continuous(name = "Time (days)", breaks = seq(0, 60, 10)) to the plot.
  • Add x-axis label by adding scale_y_continuous(name = "Weight (grams)")
  • Change the position of the legend by adding theme(legend.position = "top").
  • Observe the difference between the weights of the rats in Group 1 and those in the other two groups