Creating bar plot with error bars using ggplot2's stat_summary in R (CC318)

Поделиться
HTML-код
  • Опубликовано: 30 дек 2024

Комментарии • 12

  • @luckybarrel7829
    @luckybarrel7829 Месяц назад +2

    There is an inbuilt function for sd. It's called mean_sdl. The default is mean +/- 2SD, so you need to pass on arguments to get mean +/- 1SD.
    So the function will look like:
    stat_summary(fun.data = "mean_sdl", fun.args = list(mult = 1), geom = "errorbar", width = 0.4)
    That list(mult = 1) is the multiples of SD that should be computed, and by default it is kept to 2 since looking at overlap of errorbars plotted with 2SD gives a good indication whether a result is significantly different or not by a t-test.

  • @zgl9764
    @zgl9764 Месяц назад

    Great video, I really enjoy watching you code!

    • @Riffomonas
      @Riffomonas  Месяц назад

      My pleasure - thanks for watching!

  • @erikp6614
    @erikp6614 4 дня назад

    Very nice video!!! As an alternative to changing the y axis (around 25:40) one can use the expansion function. The expansion function let you choose multiplicative and additive expansion of the y axis.

    • @Riffomonas
      @Riffomonas  4 дня назад

      Thanks - I personally find expansion() not super intuitive. I'll have to keep working with it

  • @lucasamoroso92
    @lucasamoroso92 Месяц назад

    Great video! I wish patterns within graphs were more natural to ggplot syntax, there are cases where they can be very useful (not in this case though haha)

    • @Riffomonas
      @Riffomonas  Месяц назад

      Thanks! Stay tuned for Wednesday's video 🤓

  • @ColinDdd
    @ColinDdd Месяц назад

    the whole thing where error bars sometimes are standard error and sometimes standard deviation is so weird to me. what is the story with that!
    i ran into this trying to see what geom_errorbar(stat="summary") was doing, i think it is +/- one standard error, similar to what you saw with it defaulting to mean_se(). i guess sometimes good to see the underlying distribution vs the simple bar :)
    also pretty odd that you have to manually place the error bar, i wonder if there is a more natural way to get it to the right center position. but as always, great video!

    • @Riffomonas
      @Riffomonas  Месяц назад +1

      Thanks for watching! It seems everyone has a different opinion on SD/SE 🤣

  • @zgl9764
    @zgl9764 Месяц назад

    Great video, I really enjoy watching you code!