Using Grouping to Create a Summarized Plot

In this section, we'll use grouping to summarize multiple y values for a given x value. Let's begin by implementing the following steps:

  1. Use grouping to group by genre and remove NULL values:
gp_scr <- group_by(HollywoodMovies,Genre)gp_scr <- na.omit(gp_scr)
  1. Calculate the mean and standard deviation using the summarise function and make a new dataset, as follows:
dfnew <- dplyr::summarise(gp_scr,as_mean=mean(AudienceScore),as_sd=sd(AudienceScore),n=n())
  1. We want to make a plot with scores ordered by means. Follow the steps in the code to do so. Plot the means, as follows:

  1. Make the final plot, ...

Get Applied Data Visualization with R and ggplot2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.