1 00:00:06,830 --> 00:00:11,760 So, before we can plot something which just need to have a little bit of data 2 00:00:11,760 --> 00:00:14,160 that's very easy to create. 3 00:00:14,160 --> 00:00:18,130 That is a rnorm function which samples from a normal distribution. 4 00:00:18,130 --> 00:00:24,590 So by default we have mean zero and standard deviation one so let's sample hundred points here. 5 00:00:24,600 --> 00:00:29,630 And let's do the same for y. 6 00:00:29,630 --> 00:00:41,560 and actually increase the standard deviation a bit. 7 00:00:41,560 --> 00:00:47,530 And now we create a data frame and it’s data.frame and you say just (x,y). 8 00:00:47,530 --> 00:00:51,960 If you now view this data frame we see here 9 00:00:51,960 --> 00:00:54,130 that you have the two columns 10 00:00:54,130 --> 00:00:56,290 And you see here the numbers are a bit higher 11 00:00:56,300 --> 00:00:59,830 because the standard deviation is higher. 12 00:00:59,830 --> 00:01:01,160 And now we can plot it. 13 00:01:01,160 --> 00:01:10,090 So we have to import a library (ggplot2). 14 00:01:10,100 --> 00:01:17,130 And then we can actually plot it so we say ggplot 15 00:01:17,130 --> 00:01:21,130 plus parameters of course the data frame 16 00:01:21,130 --> 00:01:29,330 And I won't go into detail here 17 00:01:29,330 --> 00:01:32,360 because ggplot is relatively complex 18 00:01:32,360 --> 00:01:36,360 but a very, very powerful library. 19 00:01:36,360 --> 00:01:46,590 We are basically saying here that we want to draw points. 20 00:01:46,600 --> 00:01:53,100 So you see here that on the x-axis and the y-axis 21 00:01:53,100 --> 00:01:55,100 we are just plotting those points. 22 00:01:55,100 --> 00:02:00,160 Okay, now let's actually plot something more nicely. 23 00:02:00,160 --> 00:02:05,730 So there is a data frame build into R which is called mtcars. 24 00:02:05,730 --> 00:02:11,090 And it has different types of cars, and their properties. 25 00:02:11,100 --> 00:02:14,630 So it's a nice data set to play with. 26 00:02:14,630 --> 00:02:18,760 And as I said ggplot2 is relatively complex 27 00:02:18,760 --> 00:02:22,760 so I'm just copy-pasting the code 28 00:02:22,760 --> 00:02:26,760 for plotting something really nicely. 29 00:02:26,760 --> 00:02:37,390 So this is basically the weight of the car over the mileage. 30 00:02:37,400 --> 00:02:41,400 And you see here the more heavy the car gets, 31 00:02:41,400 --> 00:02:43,130 the less is the mileage. 32 00:02:43,130 --> 00:02:47,030 And in addition to that you are also drawing 33 00:02:47,030 --> 00:02:51,990 a regression line and also a confidence interval or a standard deviation. 34 00:02:52,000 --> 00:02:55,760 So that's pretty cool with only two lines of code 35 00:02:55,760 --> 00:02:59,760 You can create plots which you find 36 00:02:59,760 --> 00:03:03,730 in the best (scientific) publications because the best publishers 37 00:03:03,730 --> 00:03:08,860 often use R and ggplot2 for creating that plot. 38 00:03:08,860 --> 00:03:10,160 Okay, I hope this helps. 39 00:03:10,160 --> 00:03:11,530 If you have any further questions, 40 00:03:11,530 --> 00:03:14,660 please let me know in the Comments section below. 41 00:03:14,660 --> 00:03:17,030 And have a nice day. Bye!