Exercise

Red wine tasting

In this exercise, you will have a look at the distributions of ratings for red wines from four different countries. The data are already pre-loaded in a data frame called red_wine_data. Check out the data in order to get a feel for it before you begin!

To obtain a histogram for each type of red wine, you will need to first rearrange the data into subsets. Use the subset() command to do this. Given a data frame, this function returns a new data frame containing only the elements that satisfy some condition. For example, red_wine_data$condition == "France" returns only the subset of data pertaining to French red wines.

Instructions

100 XP
  • Inspect the red_wine_data data frame by printing it to the console.
  • Provide some summary statistics for red_wine_data using the describe() function.
  • Split the data frame into one subset per country, as instructed above.
  • Make four new variables that contain the Ratings data from each of the newly created subsets. Use the $ operator.
  • Code is provided for you to organize your histograms into a 2x2 matrix using the par() function. Don't change this.
  • Plot a histogram of the ratings for each country using hist(). Display them in the same order as you defined them. Give your histograms sensible titles and label the x-axes with "score"