Data Science Initiative Introduction To R Bootcamp (part 2)

Okay the second you’re gonna show this to somebody else you might as well clean it up and it should and it K so in this case we can go down and we can say okay we could change the X lab using X lab but we can also basically go down and say hey change the labels.

And whenever you where we said color I want you to use baths okay when we said shape I want you to use some other string okay and otherwise ggplot will just sort of you it’ll fill in the defaults very kindly others okay so if we just.

This is a slightly different plot but it’s a similar plus okay this goes back to the old one now you see we got Babs in here rather than ordered bath okay and likewise we could change the.

X lab down here go ahead and play with us I didn’t know how to do that because I don’t actually use gg+ okay why cuz I’m old and B I.

Can do everything I need with all the other graphic systems so it’s just you you pick one or the other but you can I I know how to use GG plus I don’t remember all the details but one of the things you actually kind of do is say hey okay so this is I don’t there’s a real trick there’s a.

Magic we’re all we all do it differently this is what I typed into Google I said ggplot cuz I know what to do with ggplot I want to change the legend title okay cuz okay so this is when we got the plot when we got the plot over here okay we ended up with ordered bath and I needed to.

Know how to change this so what did i do I just type this into Google and Google being Google okay I look at this and I see what do I want these are all pretty darn good hits but you know it makes me happy when I see Stack Overflow is the first one because there’s a good chance that it will actually answer.

My question directly and then it goes down you look at this how many of you have visited Stack Overflow before okay just it’s really.

Useful just and just take a little bit of use it takes a little bit of experience to actually know how to navigate your way through an answer but basically this is the question there are good bad ways to answer questions right asking a good question is really hard but then basically there’s some answers to it here this is an answer it’s kind of got our answer but not.

Quite okay because it’s fill rather than color or shape okay so you could infer this hopefully somebody has come down and this is the actual answer Jake this is the one that was voted most appropriate okay so that’s always a good bet to look at okay but not always it’s not always the best.

Answer but that was the one that was voted best at a certain moment in time in fact actually I’m not sure this one really answers the question at all properly okay so this is a but as you wander your way through you also see that there’s issues about how much how much reputation each.

Person has go for the guys who actually have answered 12 million questions before yeah we’ll talk about that a second very good question okay okay so so this one here this is exactly what you don’t do okay this is like let me go in and change all.

The internals of my applause and make it happen but it’ll break in in other ways so there’s an art to reading these different things but here this is kind of this is the answer that gate you know this tells you.

Look oh labs color equals that labs fill equals this okay let me try this and I and lo and behold off we go okay and the interesting thing is I would have commented but my Stack Overflow reputation is not enough just to comment but they gave it a good answer okay so so this this this is how we look this up okay so we can actually start building these these things we can start fixing up these plots we have complete control of almost everything okay you can.

Even change whether the gray background you can have all these themes you can spend the rest of your life playing with ggplot okay and.

It’s not a bad thing to do because we make an awful lot plots and you said why do we assign a plot let’s do this and just let me just it’s just it.

It’s la I’m just gonna kill.

This window so there are there is no window now let’s look at the plot there’s no plot okay this is a little thing I mentioned.

No plot because I said create do this computation and assign the result to Pete okay and that remember what I said if I say if I say one through three are says well you didn’t assign it to anything I should print the.

Result so now if I do this I say okay fine that’s called Z is equal to 1 through 3 r doesn’t print the result because I did assign it to something ok my trouble might.

But I assign this to P which means R didn’t print it so let’s just look at what let’s look at.

What’s in P that was enough to generate my plot okay which was very unfortunate because I really wanted the old window back again now okay because now I’ve.

Gone and done ok this is a night I’ll fix.

This in a moment ok it’s the printing of the plot that actually makes it up here ok and that’s very useful because a so.

Why because one of the things we’ll do we’ll do it down here I think ok is this okay bear with me for a second just I’m jumping ahead here is I’m creating a plot ok creating a plot so this is a scatter plot this is X this is y I’m ok I’m ok it notice while I’m well we’re here I’m basically saying.

Here’s a plot with it using this data it’s got to its here’s the X here’s the y lock that down for every layer from now on we’re gonna we can create multiple layers ok now I want you.

To draw a scatter plot and by the way I want you to inherit the X and the y from here but I want to specify the color here ok colored of ordered bath ok so you can actually specify the aesthetics in two different places they may actually conflict or one may override the other that’s fine but now okay this is a.

Foot against price colored by this this is one of the things.

I want to do okay okay okay now it’ll be very hard.

To see big well fix this in a moment okay what it’s actually done is tiled this okay it’s split it up into this faceting okay okay based on another based on a on another.

Command they added if I’d done it a different way I would actually get them stacked this way I don’t know which one I want again you can’t see it and I’m not gonna fix it quite yet but okay where are we gonna do here.