Using the the ggplot2 R package to create a boxplot with individual data points overlayed (CC091)

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2024
  • A boxplot shows the median of a distribution along with the 25th and 75th percentiles as well as an indicator of which points are outliers. In this episode of Code Club, Pat will use ggplot2 with the geom_boxplot, geom_jitter, and stat_summary functions to create a boxplot with the individual data overlayed on the figure.
    Pat will use RStudio and functions from the #ggplot2 package including #geom_boxplot, #geom_jitter, and #stat_summary and other packages from the tidyverse. The accompanying blog post with the R code that Pat starts with can be found at www.riffomonas.org/code_club/....
    Do you have a figure that you would like to receive a critique or help improving? Let me know and I'd be happy to arrange a guest appearance!
    If you're interested in taking an upcoming 3 day R workshop, email me at riffomonas@gmail.com!
    R: r-project.org
    RStudio: rstudio.com
    Raw data: github.com/riffomonas/raw_dat...
    Workshops: www.mothur.org/wiki/workshops
    You can also find complete tutorials for learning R with the tidyverse using...
    Microbial ecology data: www.riffomonas.org/minimalR/
    General data: www.riffomonas.org/generalR/
    0:00 Introduction
    1:37 Creating box and whisker plot
    6:34 Adjusting appearance of plot with alpha
    8:15 Overlaying jittered data
    11:00 Changing length of whiskers with coef
    13:29 Replacing geom_boxplot with stat_summary
    16:47 Critique of figure
    18:36 Conclusion
    #ggplot2 #geom_boxplot #geom_jitter #stat_summary
  • วิทยาศาสตร์และเทคโนโลยี

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

  • @Riffomonas
    @Riffomonas  3 ปีที่แล้ว +3

    What do you think of adding a boxplot to a jitter plot without including the whiskers?

  • @TheSandrao89
    @TheSandrao89 ปีที่แล้ว

    Absolutely love your videos! Keep up the great work

  • @mocabeentrill
    @mocabeentrill ปีที่แล้ว

    Grade A, Top shelf stuff!

  • @cyrillejar1914
    @cyrillejar1914 3 ปีที่แล้ว

    Really interesting !!! Many thanks !
    I think I will use jitter plot with box plot for my next analyses. But I will keep the whiskers, without you miss the extreme values ... I'm not sure it is really important to explain the 1.5 times about whiskers, I think it is enough to say that above or below we consider the values as extreme.
    Thanks again, even if do not agree for whiskers I really appreciate your point, an I always learn new things !

    • @Riffomonas
      @Riffomonas  3 ปีที่แล้ว

      I'd suggest that most people will want to know why you think something is "extreme" and so it's probably necessary to explain what the whiskers represent

  • @drjzee
    @drjzee 3 ปีที่แล้ว +2

    I would have thought it was a 95% CI, so I learned something there.

    • @Riffomonas
      @Riffomonas  3 ปีที่แล้ว

      HA! :) Glad to hear it

  • @KN-tx7sd
    @KN-tx7sd 2 ปีที่แล้ว +1

    Hi Pat, is it possible to reduce the space between the two x-labels so the plots are near to each other.

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      Try changing the width of the figure in ggsave

  • @user-uw6ng4hs2t
    @user-uw6ng4hs2t 3 ปีที่แล้ว +1

    Hello!! can i get a sentence for drawing Boxplot without min and max? just a box without a line!
    I know you explained it but English is not my first language so it's kind of hard to understand the whole thing...

    • @Riffomonas
      @Riffomonas  3 ปีที่แล้ว

      Hi there! You can do it with stat_summary(fun.data=median_hilow, geom="crossbar"). Alternatively, you should be able to use geom_boxplot(coef=0, outlier.color = NA)

  • @KN-tx7sd
    @KN-tx7sd 2 ปีที่แล้ว +1

    Hi Pat, is it possible to pin the number as you have shown for the x-axis labels for the Titles and subtitles, and captions. Thank you

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      You can do that with the glue function as well

  • @hassanhijazi4757
    @hassanhijazi4757 2 ปีที่แล้ว +1

    Hi Pat, does the position of the jittered points change each time you run the code or itmust be fixed at each code-run?

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      It’s determined by the random number seed. You can do set.seed or (I think) geom_jjtter has an argument to set a seed

    • @hassanhijazi4757
      @hassanhijazi4757 2 ปีที่แล้ว

      @@Riffomonas Exactly, thank you. I checked that you can provide the argument "position = position_jitter(seed = NULL) inside the geom_jitter() and it will do it.

  • @erdenebilegnasantogtokh6705
    @erdenebilegnasantogtokh6705 ปีที่แล้ว

    How to fix some error,
    library("tidyverse")
    Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j = 3.4.0 is required
    In addition: Warning message:
    package ‘tidyverse’ was built under R version 4.1.3

  • @The_Researcher_Girl_Aditi
    @The_Researcher_Girl_Aditi 3 ปีที่แล้ว +1

    how to do Box and Whisker Plot in R?? Please Urgent 🙏😭

    • @Riffomonas
      @Riffomonas  3 ปีที่แล้ว +1

      You’re in the right place! Check out this video and you’ll learn how

  • @mdmominulislam2498
    @mdmominulislam2498 2 ปีที่แล้ว

    is it possible to do it in excel.please make a video.combining jitter plot with box plot in excel.thanks

    • @Riffomonas
      @Riffomonas  2 ปีที่แล้ว

      Thanks for watching! Unfortunately I don’t know how to use excel to make figures 😂 maybe this is a good chance to learn some R to improve the reproducibility of your code?

  • @saadalhumaid3959
    @saadalhumaid3959 ปีที่แล้ว +1

    Master

    • @Riffomonas
      @Riffomonas  ปีที่แล้ว

      Ha! Well I don't know about that but thanks for watching 🤓

    • @saadalhumaid3959
      @saadalhumaid3959 ปีที่แล้ว

      @@Riffomonas dude u brilliantly not surprised u hold a PhD degree. Stuff u know in RStudio should raise ur chance in the authorships in the best international journals

  • @valerierussell6867
    @valerierussell6867 ปีที่แล้ว

    Yeah, I thought the whisker was the entire range....

  • @pingliu1310
    @pingliu1310 3 ปีที่แล้ว +1

    I called it jitter plot. 😀

    • @Riffomonas
      @Riffomonas  3 ปีที่แล้ว

      I think I'm slowly changing from strip chart to jitter plot 🤷‍♂️