Data Visualization - Bar Charts, Histograms, and Box Plots- Screen-5

Hi Sahil,

In the exercise code :
ggplot(data = reviews) +
aes(x = Rating) +
geom_histogram(bins = 30) +
facet_wrap(~Rating_Site, nrow= 2)

How we got 4 different plots without using group_by() coz data = reviews is mentioned in ggplot() instead of data= review_avgs

Hi @sharathnandalike. We get four different plots here because we use the facet_wrap() function which creates a separate plot for each unique value specified in the function argument. In this case we are faceting by Rating_Site, which has four unique values. We can double check this with:

And we see that there are four rating sites:
[1] "Rotten_Tomatoes" "Metacritic" "IMDB" "Fandango"

Your logic is correct to think about group_by() here. In this case the ~ (“til-deh”) means “by”, so here we are “faceting by” Rating_Site.

I hope this answers your question. Please let me know if you have any follow-up questions. Best,

1 Like