This lesson requires a premium membership to access.
Premium membership includes unlimited access to all courses, quizzes, downloadable resources, and future content updates.
Ask questions about this lesson and get instant answers.
Faceting refers to splitting the data into multiple subsets and then displaying plots for the specific subsets in a panel. Such plots are also called small-multiple plots. The facet approach partitions a plot into a matrix of panels. Each panel shows a different subset of the data.
In our scatter plot we grouped the data into bad and good loans using colors. We can use the faceting concept to split the entire graph into two separate panels one for each, good and bad loans. To do so we will use the facet_grid(. ~ ___) layer. facet_grid forms a matrix of panels defined by row and column faceting variables. facet_grid(x ~ y) will display x*y plots even if some plots are empty.