Beautiful Charts with R & ggplot2 (Step-By-Step Tutorial for Beginners)

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2024
  • FULL CODE AND DESCRIPTION:
    DESCRIPTION:
    ggplot2 is an incredibly powerful tool to create great charts with R. But it has a bit of a learning curve. This tutorial shows you everything you need to know to get started with ggplot in 45 minutes
    FULL CODE:
    The corresponding blog post to this video (including the full code) can be found at albert-rapp.de/posts/ggplot2-...
    WANT TO GET EVEN BETTER?
    You have started to learn the mechanics of ggplot. That's a great start. But if you want to create insightful charts, then you will have to combine ggplot with data visualization principles. If you're interested in that, then check out my video course at arapp.thinkific.com/courses/i...
    LINKS TO THINGS I'VE MENTIONED:
    🔗 Quarto: If you've never used Quarto files to mix texts and code chunks, then you can find all of that information about this incredibly powerful tool at quarto.org/
    🔗 TidyTuesday: github.com/rfordatascience/ti...
    🔗 Allison Horst: The idea to create an ugly chart to learn the mechanics first wasn't my idea. I picked that up from one of Allison's blog posts. You should check out here website (and her great educational cartoons) at allisonhorst.com/
    MORE VIDEOS
    📺 Avoid duplicate R code in 150 seconds • Avoid duplicate code w...
    📺 Shiny modules in 100 seconds • Shiny Modules in 100 S...
    📺 Fast explainer playlist • Explainer videos
    Subscribe at 👉 / @rappa753
    MORE CONTENT
    - weekly 3-minute newsletter about R, DataViz and webdev at alberts-newsletter.beehiiv.co...
    - LinkedIn at / rappa753
    #rstats #dataviz #ggplot2
    TIMECODES
    00:00 Intro
    00:30 First Chart
    01:43 What the heck is aes()?
    03:50 Why coordinates in aes() & scales?
    05:07 Use a real data set
    06:19 Set aesthetics to fixed values
    07:20 Make color dependent on data
    09:30 Avoid code repetition
    10:12 Nicer labels & titles
    10:58 theme_*() layer and font size
    11:38 theme() function: using values for changes
    12:50: theme() function: using elements
    15:29: Try out scales
    16:21 Our first bar chart
    17:50 Statistical transformations
    19:00 Trying to work with statistical transformation
    20:30 Identical statistical transformation
    21:20 Creating a histogram with a stat_* layer
    22:40 Connection between stat and geom layers
    24:10 Easier layers without touching stat
    24:45 Add labels to bar chart
    27:00 Formatting the labels
    27:45 Change color of bars
    28:40 Remove more duplicate code
    29:40 Split histogram by sex
    31:30 Change positioning of colored histograms
    33:03 More position changes (dodge and jitter)
    35:44 Use multiple windows for different histograms
    37:00 Putting it all together with a new data set
    44:20 How to learn more?
    45:02 Shameless plug & outro

ความคิดเห็น • 20

  • @rappa753
    @rappa753  7 หลายเดือนก่อน +1

    If you want to get even better at ggplot and create insightful charts, then you can check out my video course arapp.thinkific.com/courses/insightful-data-visualizations-for-uncreative-r-users

  • @DM-py7pj
    @DM-py7pj 2 หลายเดือนก่อน +1

    dark mode + properly zoomed + logical well-paced instruction = straight in my faves

    • @rappa753
      @rappa753  2 หลายเดือนก่อน +1

      Glad that you like my style ❤️

    • @DM-py7pj
      @DM-py7pj 2 หลายเดือนก่อน

      @@rappa753 you are IMO an excellent teacher. Working my way through your content currently. Thank you for providing such high-quality material for free.

  • @difflocktwo
    @difflocktwo 8 หลายเดือนก่อน +3

    For a casual R user, myself, this is great. The video format, pacing, audio quality and everything; great.

    • @rappa753
      @rappa753  8 หลายเดือนก่อน

      Nice. So glad that you enjoyed it. I put a lot of thought into this one 🤗

  • @Aaqib..
    @Aaqib.. 8 หลายเดือนก่อน +3

    Really grateful for this. This is a power packed video, informational and compact. Thanks again sir

    • @rappa753
      @rappa753  8 หลายเดือนก่อน

      You're welcome 🤗

  • @leadrevolver
    @leadrevolver 8 หลายเดือนก่อน +2

    Thanks for the really nice intro, I'll share it.
    Personally, I'm a bit more advanced, currently learning how to expand the base package.

    • @rappa753
      @rappa753  8 หลายเดือนก่อน +1

      Thank you for sharing 🤗🥳

  • @ambhat3953
    @ambhat3953 หลายเดือนก่อน

    Though I've been using ggplot for few years I was still able to learn new things about scale x continuous and adjusting geom text. Thx
    Btw, I think it would have helped newbies if you had shown 'group' parameter in geom line.. That's always needed in geom line and it's not very intuitive when you look at documentation

    • @rappa753
      @rappa753  หลายเดือนก่อน

      Nice! I'm always oddly happy when my beginner's content also has nuggets for advanced users 🥳🤗 As for the group aesthetic, that's true. This could have been an easy add-on 🤔

  • @MrSainforce
    @MrSainforce 7 หลายเดือนก่อน

    Very nice and helpful introduction to ggplot! Do you also plan to create such an introduction to data wrangling?

    • @rappa753
      @rappa753  7 หลายเดือนก่อน

      Glad that you enjoyed it 🤗 and yes, there's a lot of intros that I want to create in the next couple of weeks 🥳

  • @alphaena1
    @alphaena1 8 หลายเดือนก่อน +2

    how do i insert those bars on the left side of the R code

    • @rappa753
      @rappa753  8 หลายเดือนก่อน +1

      That's a setting in RStudio. It's called rainbow indent

    • @oluwafemioyedele
      @oluwafemioyedele 8 หลายเดือนก่อน

      Please how do I add the rainbow indent in R Studio?

    • @oluwafemioyedele
      @oluwafemioyedele 8 หลายเดือนก่อน

      I click on tools; then global option; then I click on code; then I click on Display then I check Use rainbow parentheses then I apply it but I cannot see those bars in which you have at the left. Please can you walk me through on how I can set this up ?

    • @rappa753
      @rappa753  8 หลายเดือนก่อน

      You're on the correct page. On the same page, you should be able to find "Indentation guides". In the dropdown menu select rainbow fills. If you don't see that in your settings, you might have to update your RStudio.