 It's LinkedIn Learning author Monica Wahee with today's data science makeover. Watch while Monica Wahee demonstrates how to format data for ggplot2 in R. Hi, everyone. I'm going to show you a real life use case. I like that term use case. Kind of reminds me of suitcase. I wish we were on vacation. Okay, anyway, the purpose of our little meeting here is for me to tell you that the package ggplot in R, a very popular plotting package, is like Excel in that it wants you to format your data for it before you go make your plot. So let me show you about that. I'm using some of my friend's data for a demonstration. I helped him make a plot for his paper. It's actually a really good paper, I think. Anyway, these data are about, well, let me just run this and show you. I already ran this line. I'll just run this data set. Okay, pay close attention. In his study, he had four groups, groups of like plates or mice. I can't remember. It was like a lab study. Read the article, I guess. I write so many articles. I think it was mice. Anyway, this was the group label. So remember that group. Okay, so each row of this table is a measurement he did. That's how you have to think about a ggplot table. Each row represents a value and every column that's not that value represents an attribute. So group is a first attribute. And then measure is the second. See, this is the measurement he took that corresponds to that value. Actually, this mean here is the value that this group and measure are about. So we already did the data processing and determine the mean value for group A, for the measure of his sto C E J A B C, whatever that is, I work on too many papers. That's what I'm saying. So you have to prep your data for ggplot. It's not like SAS where it wants to grind through it on the fly. Okay, and while I was at it, I threw the standard error in there. Okay, that's what I wanted to show you. Let's go back to the code. All right, here I load the ggplot to library. And here's my basic default plot with default colors that I'm so sick of. Just a reminder. So we start the ggplot call with an open parenthesis. We specify our special data set made just for ggplot and we have the AES argument. I think this stands for aesthetics. So in the AES, we are telling it that the x we want is measure. Oh, I forgot to tell you we are making a bar plot. So remember that his sto C E J A B C measure, that's what will be on the x axis as one of the bars. Then we have y equals mean. And that makes sense. We want the bar to be as high as the mean on the y axis. And the fill is group. Remember group, that's that a b c d variable. So fill equals group means color code them by group. Now those of you who know how gplot works, you know you have to put a plus at the end of each line, and then keep layering it on. So let's look at what we put on our next slide. Yep, it's geome underscore bar. So now we can see it is a bar plot. Position equals position dodge means don't stack the bar plot. Just put the bars side by side. And stat equals identity means just graph the mean, which is the identity of the statistic. Then I have a y label and an x label. Okay, I'll just admit it, I typed this mu symbol in word, and then copy pasted it into the code. I'm not good like you guys. Okay, let's highlight and run this ggplot code. Let's see what happens. Okay, so normally at this point, I would say this is gorgeous, magnificent, actually magnifique. But I'm sorry, it's only like, like, okay, the colors are default. And that is so, you know, like not cool. It really does not say something good about you. If you use the default colors, and you know who you are. So that's why in my next video, I'm going to show you how to use the online app coolers to fix this default color ugliness problem. And then your data will truly be gorgeous. Thank you for watching this data science makeover with LinkedIn Learning author Monica Wahee. Remember to check out Monica's data science courses on LinkedIn Learning. Click on the link in the description.