Introduction to ggplot in R
Vložit
- čas přidán 7. 07. 2024
- Introductory video tutorial on using the ggplot2 plotting system in R and RStudio. Please view in HD (cog in bottom right corner).
Download the R script here: drive.google.com/open?id=1aWs...
Download my "theme_hefin" from here: drive.google.com/open?id=1yli...
This gets looked over so much in so many books. Great job getting down to the basics.
For those wondering how he color codes the functions:
Tools > Global Options > Code>Display> "Highlight R function call"
this right here is the definitive video on the internet for plotting in R. thank you!!
1:17:24 felt like the end of a fruitful semester. THANK YOU Hefin!
Really great video! Just wanted to put this out there in case anyone else had this issue. When using a summary statistic in geom_bar, the argument fun.y has been depreciated. It is now simply fun.
So instead of: geom_bar(stat = "summary", fun.y = "mean")
It is now: geom_bar(stat = "summary", fun = "mean")
Thanks man, that saved me from spending another 15 minutes looking for solutions!
I was scratching my head. thanks!
I can't thank you enough, this is the best and easy to understand video on ggplot and R !!
Same, thank you
Thank you so much for demystifying R to me. I feel now more confidence in R. Stay blessed
finally a thorough explanation of ggplot2! so much easier to understand! thank you so very much!
This is by far the most helpful tutorial i've come across so far, thanks!
Thanks a lot!! This is just what I was looking for to be able to stop being limited to the bar charts of excel. Really well explained!
Very nice introduction to R and the ggplot function. Thank you for clarifying so many things!
I actually bought a course and it didn't explain ggplot as clearly as you could! definitely going to be using the rest of your videos. you are awesome and I hope all the things that are good in this world come to you.
Hi Ryan! Glad I could be of some help. I'd be happy to hear any feedback you have for any other topics you would like me to cover.
Thanks for this! Had to do some last minute ggplot-ing for a lab meeting, and this just saved me!
Really nice job!
Thank you, very well explained in a way that logically scaffolds the information and doesn't assume you know anything - recommend this vid.
Your lectures are so good. Seriously you are the best lecturer!! I really wish to watch more videos... THANK YOU!!!
you catapulted my understanding on ggplot from 0 to a very decent amount to fly by myself, and to stop being scared of all those functions that didn't make sense to me.
Great tutorial! You so nicely explained the basic principle of making graphs with ggplot2 (something which I had difficulty grasping through text-based tutorials). The examples and explanations were great. Thank you! Highly recommend this tutorial for beginners.
Everything I need to know. Thanks for taking the time to make these videos!
I am relatively new to R and I didn't even touch ggplot because I found it so confusing. This tutorial here has single-handedly removed most of my fears. Great work. I hope someday you create tutorials on handling Geospatial data too.
you prolly dont care but does anyone know a method to log back into an instagram account?
I was dumb lost the password. I would appreciate any tricks you can give me.
Man this is so great. Congrats on your work, you're very clear. Keep it up!
This video is the best ggplot tutorial without any BS in it!
I am always amazed at how simple graphs that are done with a few clicks in Prism can be so complicated in R!
Initially it might seem like that, but graphs in Prism are relatively ugly compared to what you can create in R, the types of graphs Prism will produce is finite, and R is free.
Thanks for your good demonstration. It's a pretty good guide for ggplot beginner.
Super useful and clear! Thank you sooo much!!
Great started video on ggplot. Great explanation of all the components like AES. Thank you.
Glad you found it useful!
Great Job Hefin. Clear explanation and examples.
Thank you nreedus!
thanks for the clear explanation and demonstrations! It is super useful for beginners like me. please keep it up the great work!
Hi Hefin, just want to compliment your video. Really good content, starting at the foundations and working up. Recommend this to any beginner or even intermediary R user.
Thank you! (Especially for linking to the script)
Outstanding tutorial, Thank you very much!
Awesome video! So easy to understand and use. you are a great instructor!
Thank you Alona!
Your video is a good basis for working with plots. Thanks for that.
You are most welcome!
Hi Hefin, thank you for the wonderful and best video. I really enjoyed it and learned a lot.
This is simply awesome...thanks a ton!! Your explanation was spectacular for a beginner like me..thanks again!!!
Glad you enjoyed it! I hope you have lots of success using ggplot.
Very well explained. Thank you!
Great! There are many practical points.
very well explained ... thank you
Many thanks for creating this. I found it very useful.
Great! Much love and thanks for your work buddy!
Excellent video for starting up with ggplot, good job!
Thank you Markus! Glad you enjoyed :)
Great video. I appreciate that you go slow and don't speed up the typing and then move on. This is how an introduction course should be. Thank you. A typical hour-long course will take me four hours to get through, yours only took a little less than two because it goes at a natural pace.
Vielen Dank! Sehr gutes Tutorial!
Thanks so much. It was really great video which actually explained aes well.
Gaurav Pandey Thank you! I'm glad you found it useful. There's so much more you can do with ggplot, the best way is to play with it and try to do new things with it.
Thank you so much, very helpful and informative.
Thank you! I hope it helps.
Absolutely fantastic video.
Thank you!
Great, well-explained tutorial! Thanks!
BTW, gre is the graduate record examination, a test that you have to take to apply to most of the US graduate programs
thanks, I watched every minutes, some parts twice. please upload more basic R video!!!
So much better than my prof😁 Thank you!!
AWESOME LESSON.. HAD TO SAVE THIS AND SUBSCRIBE ALSO... THANK YOU!
Nice explained! Thank you!
This was SUPER-useful. Thanks a lot! :)
You're most welcome!
Thanks for this, really useful.
You are a lifesaver! Thanks a lot!
Thanks again Hefin! :) I understand now I have to use fun instead of fun.y. :)
Great video, many thanks!
Thank you Hefin:))
Thanks Hefin. This helps alot
@Hefin Rhys Splended!
Your videos are Gems!!
Awesome tutorial for beginners
Thank you! Glad it helped.
Well done!!! Thank you!
Wow, Thank you!!! Please some more
great tutorial
Fantastic video
Awesome tutorial for me
Great video!:)
great tutorial!
thanks. liked it a lot
Lin nn Thank you! I'm glad you liked it.
Thanks, really useful :)
U r the best. thanks !
@Hefin Rhys, what distro are you using? ;) Awesome tutorial btw!
Hi Hefin, this video helped a lot! Thank you! I also wanted to ask how would I add error bars to the bar graph with the point graph?
I'm pretty sure that the method you used at 31:18 has depreciated. I found that I had to use a different method to get the same result. I had to use ggplot + stat_summary(geom = "bar", fun = "mean") That did the trick for me!
Yes I found the same thing. Another option is to use geom_bar as he did:
geom_bar(stat = "summary", fun = "mean"
(instead of fun.y, it is now just fun)
thx
Thanks so much for the very helpful tutorial Hefin.
I slightly modified the codes for the bar charts and lines.Tell me what you think.
ggplot(ToothGrowth,aes(dose,len,fill=supp))+geom_bar(stat="summary",fun.y='median')
ggplot(ToothGrowth,aes(dose,len,fill=supp))+geom_bar(stat="summary",fun.y='median',position="dodge")
ggplot(ToothGrowth,aes(dose,len,col=supp))+geom_line(stat="summary",fun.y='mean')+geom_smooth()
Hi Aniruddha! Thanks! Sorry for the late reply. Good job! I see you're experimenting with ggplot2. The plots look good. The first two have a gap at 1.5 because the x aesthetic is continuous instead of being supplied as a factor. You may want this, but I find it a little distracting. However, I think you line plot is better than mine BECAUSE you kept the x aesthetic as continuous. Thanks for sharing and happy plotting!
superb!
Hello Hefin Rhys, Thanks for the tutorial, that was very helpful. I have a question, is it possible to prepare a clustered boxplot similar to a clusted bar plot using R? I would like to prepare a clustered box plot with days( day1, day2, day3) on x axis and clinical scores on y axis. On each day there are 3 groups (test, negative and positive) that I would like to represent the data for. Is this possible? Many thanks,G
Yes you can certainly do this, simply use aes(x = day, y = score, col = group), then your geom_boxplot will automatically cluster the boxplots for you so you have three boxplots for each day. This example code does it:
d
Hey Hefin, I really can't thank you enough for your tutorials.
Could you please tell me how to get standard deviation bars for the geom_bar that we plot for the mean? I have seen many of the research papers use it. Hence I wanted to understand how its plot.
Thanks again.
kind of wondering how they calculate the CI for the median~~~~ really good video !!!!
Yes, great job, thanks. Would have liked a couple more minutes on line graphs...still struggling with issues there.
great job
Thank you!!
Thank you for the video. I have a question regarding the option of exporting or saving graph as Jpeg or PNJ. How can we keep the font size exactly the same after saving pic. I did set up fig.height and fig.witdth in '''{r}, but the title of the graph misses some characters of the end. Thank you !
i love you !!!!
THANK YOU
Hi, i'm new with R language.. good idea this video.
If I have a wave how can I take and separate the values of the crests starting from a certain threshold?
You are amazing! I honestly learned R from you. I am practising and trying to run a function to create a ggplot box using mtcars dataset to plot miles per gallon (in the variable mpg) against the number of gears (in the variable gear). and using the aesthetic to colour bars by numbers of gears. I did it but I can not colour the bars by numbers of gears! I don't know how to subdivide a variable! Can you help, please ?
Thanks.
2:10 I'm asked "Do you want to install from sources the packages which need compilation? (Yes/no/cancel) " What does it mean and what to do?
Check out this explanation and recommendation: community.rstudio.com/t/meaning-of-common-message-when-install-a-package-there-are-binary-versions-available-but-the-source-versions-are-later/2431
1:13:58 anyone else notice the magical lines appear?
geom_line(position = position_dodge(0.9)) if you were interested
Hehe thanks!
I got a lot out of this, it was in plain English and paced well. The only feedback I have is that the screen is very dark and it's incredibly difficult to read the code because it is also blurry. Suggest classic white background and black text...?
Watch in 1080p.
Is it necessary to have only numeric values in .csv file?? if we have characters as well as numeric in our .csv file, then can we make a plot? if we can, then how? as i am having a .csv file which has date, month, year, product name, its subcategory, cost, revenue and profit. i am not able to work on it. Pls suggest me some ways so that i can proceed.
Maybe because this video is old, R didn't recognize fun.y and that caused a lot of confusion. Do you know anything about why that is? I had a hard time finding an answer online.
Yes you're right it has now changed. I believe the argument is now just "fun". I'll try this later on and check that's correct but let me know if you get there before me.
@@hefinrhys8572 Thank you! Do you think all the functions/arguments your other videos still work with the current version though? I've already watched your two R introduction videos but I might watch more.
The majority of the functions and their arguments in my videos should still be current. If you find any more inconsistencies though, please do flag them up for me :)
Alrighty! Thanks again ^^
which code or function I have to use if I want to put 3 ogives in one graphic?
What theme are you using for RStudio?
I believe it's called Cobalt :)
Thanks so much for this awesome video as well! I've been using Data Camp but you've explained it so much better!
Is anyone else having trouble when they enter the (fun.y = median) function? I keep receiving errors--->
Error in FUN(X[[i]], ...) : object 'sup' not found
In addition: Warning message:
Ignoring unknown parameters: fun.y
This changed in a recent ggplot2 update, so the argument should be "fun", not "fun.y".
@@hefinrhys8572 Hey thanks a ton!
Wish you write a book on ggplot. I just loved your book "Machine Learning with R, the tidyverse, and mlr" If you don't mind, can you please suggest any book for ggplot? to further enhance my knowledge. Thanks a lot in advance mate.
Thank you! I'm glad you liked ny book :) the best book for ggplot2 is probably this one by Hadley Wickham: books.google.co.uk/books/about/Ggplot2.html?id=bes-AAAAQBAJ&source=kp_book_description&redir_esc=y
Guys, anybody, please, I am failing miserably. I need to write a script in r using ggplot that would not use any datafile, but just generate a figure with imaginary output. Where do I start ?? :(
Hi Vladimir, sorry for the late reply. So I would generate some imaginary data and save it as a data frame first like this:
vladsData
The command "fun.y" is not recognized by R :c , Idk what to do .
So ggplot2 had been updated since I recorded this, the argument is now just "fun".
I am getting these following error's while executing the command's,please help.
Error in FUN(X[[i]], ...) : object 'Petal.Lenth' not found
Try "Petal.Length" with a g. R is very unforgiving with spelling!
I knew i was doing something very stupid.
good morning sir, please anytime I try running the ggplot, i always get it wrong: ggplot(iris, aes(x = petal.length, y = sepal.width))
Error in FUN(X[[i]], ...) : object 'petal.length' not found.
I have actually tried for almost two daysnow and the same results. thank you
Hi Mohammed, R is case sensitive so you need to use Petal.Length and Sepal.Width, not their lowercase counterparts. I hope this helps!