Chapter 5: Data tidying

Set up

We have already loaded the R packages you need for this tutorial. Once you start working in RStudio, you will run code like the code shown below to load the R packages you need.

Exercises

All exercises are from R for Data Science 2nd Edition.

Section 5.3.2

Suppose we have three patients: A, B, and C, and we take two blood pressure measurements on each patient.

Suppose you want to create a bar plot with patient IDs on the x-axis and blood pressure values on the y-axis. For each patient, you display two bars: one representing the first blood pressure measurement and the other representing the second. The height of each bar corresponds to the recorded blood pressure value. How would you do it with the current data set?

We need to transform it first!

We can now use this transformed dataset! Fill in the blanks to make the plot.

Important

Try to run the code without including position = position_dodge(). What changes? Why did we add this line?

Open code chunk

Here is a code chunk in case you wish to play around with some code