In this video I'm going to show you a few more examples of how to play around with and modified bar plots. I'm also going to give you a short workout manipulating data in R. Again, we're picking up in the R code file here exactly where we left off in the previous video. Let's start by showing you a way to make a bar plot of proportions. We've seen in the past that we've made a bar chart of the number of Democrats, and Republicans, and the 115 Congress, and there we wanted R to manually count the frequency of those different values in that column. Other times though you don't want R to do this manual calculation, you don't want an R to do this calculation and we're going to tell R exactly what values to plot on the bar plot. An instance of this might be if you want to plot the proportion of different responses or different values in a column. Again, this is hard to understand the abstract, so it's easier just to go ahead and show you, and then you'll get a sense for what we're talking about here. Instead of continuing to use this survey data here, we're going to do something a little bit different. To keep things interesting, I'm going to quickly make up a toy dataset that you can use to create the visualization. Making up these little toy or fake datasets is a good way to check your understanding of how a function works, and it's a good skill to be able to whip DCEP quickly. When you're looking at reference materials online for a ggplot, you'll often see folks that are doing this. They'll make up a little toy dataset and then demonstrate the visualization using that brand new original data they've created. It's good orient yourself to the process of doing this. Let's say that I want to make a collection of fruits in a fictitious fruit bowl. First I'm going to create a set of apples, and I'll do this using the replicate function. What I'm doing here is I'm creating a character string for apple, and I put it in quotation marks here, and then I tell the function to replicate that character string six times. If I look at the object I've created, which I'm naming apple, it has six apples in it. We'll do the same thing now for three oranges and one banana. So we have 10 fruits in total. Now I put all these fruits together into my fruit bowl by creating a table that combines all of these with the C function. Now we have this very small dataset, and we can use this to create the bar plot of proportions. The first thing we need to do is to calculate the proportions for each kind of fruit in the fruit bowl, and what we want is a table that has the fruits in one column, the counts of each fruit in the next column, and then the third column we want to have their proportions. We can do all of this with some fairly simple data wrangling. We take the data, we group it by the different kinds of fruits, and then we create a column of summary data called count, which is equal to the number of observations in each group. If you need to take a minute and untangle what this command does, you should go ahead and pause the video and backtrack and make sure you understand the steps of this. After you create the counts, we can calculate the proportions for each fruit in the fruit bowl. Now this is not very exciting because in this particular instance there are 10 fruits, so calculating proportion is very easy. But you could see how you could extend this out to different numbers in the same process at work. Now we have a little table with the number of each different kind of fruit in the fruit bowl. So let's make that bar plot. I'm going to do things a little bit differently here though, and rather than map a single aesthetic, I'm going to map both the x and the y aesthetic with x as fruit and y as the calculated proportion. Additionally rather than just using the geom_bar function with no input inside those parentheses, this time I'm going to include a stat equals identity option. This is telling the function not to do its default action, which is to use that count function, but instead plot the different values for every single row of the dataset directly based on the identity of that value in the table. That's why I mapped both the x and the y, for every row map the x-value and the y-value as the top of the bar in that bar plot. For review here, we can add a few additional commands for color, labeling, and dropping a legend, and the end result is a bar plot that has three bars that corresponds with the proportion of each kind of fruit in the fruit bowl. Again keep your R code open, and in the next few lines of code we're going to do a little bit more practice yet.