As we continue working with bar plots, now I'm going to jump back to using some of our example data. This time again, the sample of survey data that we've been working with from the Cooperative Congressional elections survey. I keep switching back and forth here intentionally. Because you want to practice learning to make different kinds of visualizations with different data sources all loaded into the same R session. For this visualization, I'm going to break out the respondents, that are Democrats, Republicans and Independents. I'm going to show the count at each of these different classes of respondent by region of the country. There are four regions setup in the code book for our data. So I'm going to show the number of Democrats, Republicans, and Independents in each one of these regions using bar plots. When we're doing this, we can actually do it in two ways. One way, you could create four separate stacked bar charts with the total number of respondents in each region, and in the different parts of the different categories of party membership, Democrats, independents, and Republicans, broken out into stacked bars for each region. And the other way would be to create 12 separate bars that are grouped together into the four different regions. Again, harder to understand than to actually just see and do. So let's go ahead and give it a shot. To start, we read in the CCS data. If you look at the code book and the survey, there's a question about party identification that is posed to all the survey respondents, all the members of the general public. This survey question is a 7-point scale, where 1-3 means that the survey respondent is a strong Democrat to lean Democrat, 4 means that the respondent is a true independent, and 5-7 means that the respondent is a lean Republican to a strong Republican. We're going to recode this Data and collapse it so it's just a three-part variable for Republican, Independent, or Democrat. Now let's go to our GG plot command. On the x-axis, we want the region. And because we're doing this automated count with geom_bar, we can leave the y-axis unmapped. To create the stacked bars, we map the fill color for each bar to the collapsed party variable that we've created. You see when we run this, we get those stacked bars I was mentioning. So the fill is mapped to the count of the number of different respondents in each party category, by the four different regions of the country. Now if you didn't want to use stacked bars like this, and instead you wanted to have a grouped set of bars, all you have to do is make one small change here. What you do is you go into the geom bar function, and you set the option position to equal Dodge. This takes the stacked bar chart and breaks it apart. So you have 12 bars, that are divided into four groups. This is exactly the same information as the stacked bar chart, it's just formatted differently. Whether or not you want to use one format or the other is really a personal preference based on the way you see the visualization in what you think is going to be most useful to your reader. Of course, just like every other geom, every other GG plot function we've created, GG Plot figure, pardon me, you can fiddle with the titles, the legends and the colors, just as we had before, using precisely the same process. By now, you should have a pretty good sense for the composition of a GG Plot figure. And a good foundation for continuing to learn new kinds of figures going forward.