Introduction to ggplot in R

Sdílet
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...

Komentáře • 164

  • @BravePrune
    @BravePrune Před 2 lety

    This gets looked over so much in so many books. Great job getting down to the basics.

  • @RO-gf7je
    @RO-gf7je Před 3 lety +8

    For those wondering how he color codes the functions:
    Tools > Global Options > Code>Display> "Highlight R function call"

  • @shreyaschaturvedi1933
    @shreyaschaturvedi1933 Před 3 lety +2

    this right here is the definitive video on the internet for plotting in R. thank you!!

  • @thomasoyaro3354
    @thomasoyaro3354 Před 3 lety +4

    1:17:24 felt like the end of a fruitful semester. THANK YOU Hefin!

  • @lyssasamuel1575
    @lyssasamuel1575 Před 3 lety +7

    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")

    • @nicolaistransky7493
      @nicolaistransky7493 Před 3 lety +1

      Thanks man, that saved me from spending another 15 minutes looking for solutions!

    • @RO-gf7je
      @RO-gf7je Před 3 lety

      I was scratching my head. thanks!

  • @lizzobisou
    @lizzobisou Před 5 lety +6

    I can't thank you enough, this is the best and easy to understand video on ggplot and R !!

  • @fantasilue9410
    @fantasilue9410 Před 3 lety +1

    Thank you so much for demystifying R to me. I feel now more confidence in R. Stay blessed

  • @de_da_oo
    @de_da_oo Před 3 lety

    finally a thorough explanation of ggplot2! so much easier to understand! thank you so very much!

  • @cututorials
    @cututorials Před 2 lety

    This is by far the most helpful tutorial i've come across so far, thanks!

  • @figueblue
    @figueblue Před 3 lety

    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!

  • @Nicolas-eo7lo
    @Nicolas-eo7lo Před 3 lety

    Very nice introduction to R and the ggplot function. Thank you for clarifying so many things!

  • @lebeer13
    @lebeer13 Před 6 lety +1

    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.

    • @hefinrhys8572
      @hefinrhys8572  Před 6 lety

      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.

  • @joshuareginaldmalapit3018

    Thanks for this! Had to do some last minute ggplot-ing for a lab meeting, and this just saved me!
    Really nice job!

  • @rachaelhanna8523
    @rachaelhanna8523 Před 2 lety

    Thank you, very well explained in a way that logically scaffolds the information and doesn't assume you know anything - recommend this vid.

  • @sjhanclaire
    @sjhanclaire Před 3 lety

    Your lectures are so good. Seriously you are the best lecturer!! I really wish to watch more videos... THANK YOU!!!

  • @videogrillo
    @videogrillo Před 4 lety +3

    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.

  • @mariliisjaago1968
    @mariliisjaago1968 Před 5 lety +2

    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.

  • @adrianairina7684
    @adrianairina7684 Před 5 lety

    Everything I need to know. Thanks for taking the time to make these videos!

  • @akhileshkumar9678
    @akhileshkumar9678 Před 4 lety +4

    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.

    • @ibrahimmalcolm5406
      @ibrahimmalcolm5406 Před 2 lety

      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.

  • @federicodraetta4107
    @federicodraetta4107 Před 3 lety

    Man this is so great. Congrats on your work, you're very clear. Keep it up!

  • @rouhollahabolhasani1853

    This video is the best ggplot tutorial without any BS in it!

  • @mcyte314
    @mcyte314 Před 4 lety +1

    I am always amazed at how simple graphs that are done with a few clicks in Prism can be so complicated in R!

    • @hefinrhys8572
      @hefinrhys8572  Před 4 lety +1

      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.

  • @taiwankyh
    @taiwankyh Před 5 lety +1

    Thanks for your good demonstration. It's a pretty good guide for ggplot beginner.

  • @zoezhang1022
    @zoezhang1022 Před 5 lety +1

    Super useful and clear! Thank you sooo much!!

  • @techknowhow4802
    @techknowhow4802 Před 6 lety

    Great started video on ggplot. Great explanation of all the components like AES. Thank you.

  • @nreedus
    @nreedus Před 6 lety

    Great Job Hefin. Clear explanation and examples.

  • @muratseker6406
    @muratseker6406 Před 3 lety

    thanks for the clear explanation and demonstrations! It is super useful for beginners like me. please keep it up the great work!

  • @fransnutt1175
    @fransnutt1175 Před 4 lety

    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.

  • @TheExceptionalState
    @TheExceptionalState Před 4 lety +3

    Thank you! (Especially for linking to the script)

  • @Matt-me2yh
    @Matt-me2yh Před 2 lety

    Outstanding tutorial, Thank you very much!

  • @AC-fl1lr
    @AC-fl1lr Před 6 lety +1

    Awesome video! So easy to understand and use. you are a great instructor!

  • @alischathomas8297
    @alischathomas8297 Před 6 lety

    Your video is a good basis for working with plots. Thanks for that.

  • @gdsdhol
    @gdsdhol Před 4 lety

    Hi Hefin, thank you for the wonderful and best video. I really enjoyed it and learned a lot.

  • @mainakbose3362
    @mainakbose3362 Před 6 lety +1

    This is simply awesome...thanks a ton!! Your explanation was spectacular for a beginner like me..thanks again!!!

    • @hefinrhys8572
      @hefinrhys8572  Před 6 lety

      Glad you enjoyed it! I hope you have lots of success using ggplot.

  • @e.pharis5892
    @e.pharis5892 Před 3 lety

    Very well explained. Thank you!

  • @mohsenvigeh
    @mohsenvigeh Před rokem

    Great! There are many practical points.

  • @officesayan
    @officesayan Před 5 lety +1

    very well explained ... thank you

  • @noahmutunga1708
    @noahmutunga1708 Před rokem

    Many thanks for creating this. I found it very useful.

  • @CockTailRapz
    @CockTailRapz Před 4 lety

    Great! Much love and thanks for your work buddy!

  • @Markus76a
    @Markus76a Před 6 lety

    Excellent video for starting up with ggplot, good job!

  • @phunphun7024
    @phunphun7024 Před 3 lety +2

    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.

  • @topfundus1093
    @topfundus1093 Před 4 lety

    Vielen Dank! Sehr gutes Tutorial!

  • @gauravpandey2099
    @gauravpandey2099 Před 6 lety +1

    Thanks so much. It was really great video which actually explained aes well.

    • @hefinrhys9234
      @hefinrhys9234 Před 6 lety

      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.

  • @mcpinelo
    @mcpinelo Před 6 lety

    Thank you so much, very helpful and informative.

  • @AnnieCushing
    @AnnieCushing Před 6 lety

    Absolutely fantastic video.

  • @flora1881
    @flora1881 Před 3 lety

    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

  • @dianyuanxiaopa
    @dianyuanxiaopa Před 3 lety +1

    thanks, I watched every minutes, some parts twice. please upload more basic R video!!!

  • @jbuzzasdf4552
    @jbuzzasdf4552 Před 2 lety

    So much better than my prof😁 Thank you!!

  • @maiga4244
    @maiga4244 Před 4 lety +1

    AWESOME LESSON.. HAD TO SAVE THIS AND SUBSCRIBE ALSO... THANK YOU!

  • @stefankazakov5302
    @stefankazakov5302 Před 2 lety

    Nice explained! Thank you!

  • @vanya.antonov
    @vanya.antonov Před 6 lety

    This was SUPER-useful. Thanks a lot! :)

  • @aungmyothant4513
    @aungmyothant4513 Před 3 lety

    Thanks for this, really useful.

  • @aelhamamy
    @aelhamamy Před 3 lety

    You are a lifesaver! Thanks a lot!

  • @maartjekuilman5768
    @maartjekuilman5768 Před 4 lety +2

    Thanks again Hefin! :) I understand now I have to use fun instead of fun.y. :)

  • @alexlewis8468
    @alexlewis8468 Před 2 lety

    Great video, many thanks!

  • @user-ee7ho2kz9v
    @user-ee7ho2kz9v Před 5 lety +2

    Thank you Hefin:))

  • @kenethiceland5271
    @kenethiceland5271 Před 4 lety

    Thanks Hefin. This helps alot

  • @kamilkhel115
    @kamilkhel115 Před 5 lety

    @Hefin Rhys Splended!

  • @suavejoshokoye9456
    @suavejoshokoye9456 Před 2 lety +1

    Your videos are Gems!!

  • @anuradhapani1918
    @anuradhapani1918 Před 6 lety

    Awesome tutorial for beginners

  • @yehonatanbuskila7249
    @yehonatanbuskila7249 Před 5 lety

    Well done!!! Thank you!

  • @yibletdagnachew1755
    @yibletdagnachew1755 Před 2 lety

    Wow, Thank you!!! Please some more

  • @arunsharma-kpnig
    @arunsharma-kpnig Před 5 lety +1

    great tutorial

  • @pierpaolosoranzo2606
    @pierpaolosoranzo2606 Před 5 lety

    Fantastic video

  • @shunpeng3995
    @shunpeng3995 Před 5 lety

    Awesome tutorial for me

  • @harmenverboom2447
    @harmenverboom2447 Před 5 lety +1

    Great video!:)

  • @ditebayu7248
    @ditebayu7248 Před 4 lety

    great tutorial!

  • @kartoffelkillergm
    @kartoffelkillergm Před 6 lety +1

    thanks. liked it a lot

  • @jorgemartins7041
    @jorgemartins7041 Před 2 lety

    Thanks, really useful :)

  • @christylee5545
    @christylee5545 Před 3 lety

    U r the best. thanks !

  • @domtorque
    @domtorque Před 5 lety +1

    @Hefin Rhys, what distro are you using? ;) Awesome tutorial btw!

  • @jingyiluo1746
    @jingyiluo1746 Před 3 lety +1

    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?

  • @TidBitOf
    @TidBitOf Před 3 lety +2

    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!

    • @lyssasamuel1575
      @lyssasamuel1575 Před 3 lety +1

      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)

    • @corylopsissinensis3452
      @corylopsissinensis3452 Před rokem

      thx

  • @anigov
    @anigov Před 6 lety +1

    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()

    • @hefinrhys8572
      @hefinrhys8572  Před 5 lety

      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!

  • @jakubkaczynski4747
    @jakubkaczynski4747 Před 2 lety

    superb!

  • @mailchippull
    @mailchippull Před 4 lety +1

    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

    • @hefinrhys8572
      @hefinrhys8572  Před 4 lety

      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

  • @vikramjoshi3452
    @vikramjoshi3452 Před 4 lety

    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.

  • @whaleshark8700
    @whaleshark8700 Před 3 lety +2

    kind of wondering how they calculate the CI for the median~~~~ really good video !!!!

  • @roberterdman7268
    @roberterdman7268 Před 4 lety

    Yes, great job, thanks. Would have liked a couple more minutes on line graphs...still struggling with issues there.

  • @naylandmeitzer6293
    @naylandmeitzer6293 Před 5 lety

    great job

  • @sama-hf3yv
    @sama-hf3yv Před 3 lety

    Thank you!!

  • @minhtrungdang1853
    @minhtrungdang1853 Před 2 lety

    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 !

  • @MyMrwrestling
    @MyMrwrestling Před 5 lety

    i love you !!!!

  • @noorakazanji7423
    @noorakazanji7423 Před 3 lety

    THANK YOU

  • @Orange-xw4lt
    @Orange-xw4lt Před 3 lety

    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?

  • @issaashhab1448
    @issaashhab1448 Před 4 lety

    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 ?

  • @allybaster7961
    @allybaster7961 Před 3 lety

    Thanks.

  • @Doctorpopets
    @Doctorpopets Před 3 lety +1

    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?

    • @hefinrhys8572
      @hefinrhys8572  Před 3 lety

      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

  • @noahlove1955
    @noahlove1955 Před 5 lety +2

    1:13:58 anyone else notice the magical lines appear?
    geom_line(position = position_dodge(0.9)) if you were interested

  • @sarahpausina624
    @sarahpausina624 Před 5 lety +1

    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...?

    • @iitk68
      @iitk68 Před 5 lety

      Watch in 1080p.

  • @shivaniprasad7120
    @shivaniprasad7120 Před 5 lety

    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.

  • @danielamurphy8560
    @danielamurphy8560 Před 4 lety +2

    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.

    • @hefinrhys8572
      @hefinrhys8572  Před 4 lety

      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.

    • @danielamurphy8560
      @danielamurphy8560 Před 4 lety +1

      @@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.

    • @hefinrhys8572
      @hefinrhys8572  Před 4 lety +1

      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 :)

    • @danielamurphy8560
      @danielamurphy8560 Před 4 lety

      Alrighty! Thanks again ^^

  • @nicolearmijosvelez6032

    which code or function I have to use if I want to put 3 ogives in one graphic?

  • @steelersfan830
    @steelersfan830 Před 6 lety

    What theme are you using for RStudio?

    • @hefinrhys8572
      @hefinrhys8572  Před 6 lety

      I believe it's called Cobalt :)

    • @steelersfan830
      @steelersfan830 Před 6 lety

      Thanks so much for this awesome video as well! I've been using Data Camp but you've explained it so much better!

  • @irrationallogic7220
    @irrationallogic7220 Před 4 lety +1

    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

    • @hefinrhys8572
      @hefinrhys8572  Před 4 lety +1

      This changed in a recent ggplot2 update, so the argument should be "fun", not "fun.y".

    • @irrationallogic7220
      @irrationallogic7220 Před 4 lety

      @@hefinrhys8572 Hey thanks a ton!

  • @rizwan1220
    @rizwan1220 Před 3 lety +1

    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.

    • @hefinrhys8572
      @hefinrhys8572  Před 3 lety

      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

  • @vladimirmisin1876
    @vladimirmisin1876 Před 6 lety

    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 ?? :(

    • @hefinrhys8572
      @hefinrhys8572  Před 5 lety

      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

  • @tomassanchezpucheta2142
    @tomassanchezpucheta2142 Před 4 lety +1

    The command "fun.y" is not recognized by R :c , Idk what to do .

    • @hefinrhys8572
      @hefinrhys8572  Před 4 lety +4

      So ggplot2 had been updated since I recorded this, the argument is now just "fun".

  • @ShahidIqbal-sq7bf
    @ShahidIqbal-sq7bf Před 6 lety

    I am getting these following error's while executing the command's,please help.
    Error in FUN(X[[i]], ...) : object 'Petal.Lenth' not found

    • @hefinrhys8572
      @hefinrhys8572  Před 6 lety

      Try "Petal.Length" with a g. R is very unforgiving with spelling!

    • @ShahidIqbal-sq7bf
      @ShahidIqbal-sq7bf Před 6 lety

      I knew i was doing something very stupid.

  • @mohammedmusahduolewere2564

    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

    • @hefinrhys8572
      @hefinrhys8572  Před 2 lety

      Hi Mohammed, R is case sensitive so you need to use Petal.Length and Sepal.Width, not their lowercase counterparts. I hope this helps!