Recreating a jitter plot made with R's ggplot2 two years later (CC243)

preview_player
Показать описание
Pat loves the ability to easily make jitter plots in R with tools from ggplot2. In this episode, Pat recreates his own figure from 2 years ago and then compares the code. How similar do you think the code will be? How similar would your code be after 2 years of learning and using more R? Watch as Pat uses magrittr aliases, map_dfr, if_else, ggplot2, geom_jitter, theme, scale_x_log10, scale_color_manual, and more. This episode is a bit different than Pat's other episodes and would love your feedback on this type of content!

#geom_jitter #ggplot2 #tidyverse #R #Rstudio #Rstats

Support Riffomonas by becoming a Patreon member!

You can also find complete tutorials for learning R with the tidyverse using...

0:00 Introduction
2:09 Reading in data files with map_dfr
12:50 Building initial jittered plot
14:04 Creating a log10 scale for x-axis
15:42 Setting the color and alpha of points
16:57 Altering the theme of the figure
19:26 Changing the amount of jitter
20:48 Reversing the order of datasets on y-axis
23:09 Final formatting and saving of figure
24:51 Comparing new code to old code
Рекомендации по теме
Комментарии
Автор

Thanks Pat. Normally I let R choose my factor variable colors when geom_pointing or geom_jittering. Will now use scale_color_manual more often.

marc_CFA_applied_econ
Автор

Can you also do a video on Sankey plot, if possible ?

r-nik
Автор

14:46 rather than typing out the breaks and labels manually, how about using:
breaks = 10^(0:6), labels = format(10^(0:6), scientific = FALSE, big.mark = ", ")
It's a lot shorter, but also less susceptible to typos.

spacelem
Автор

I started dabbling in R about 10 years ago in the starting phases of tidyverse and my code was a mixture of base-R and early tidyverse and lots of loooong codelines. When COVID-19 hit in 2020, I picked up the pace of data analysis with R more and started really learning both base and tidyverse a lot better. Comparing what I do now vs even 2020 is a big(!!!) difference in terms of clean coding and efficiency.

Tip on capitalizing: stringr (loaded with tidyverse) has the functions str_to_*() which can help.
dog <- "the quick brown dog"
str_to_title(dog)
#> [1] "The Quick Brown Dog"
str_to_sentence("the quick brown dog")
#> [1] "The quick brown dog

PeperazziTube
Автор

Can you tell us the difference between working with RStudio o Visual Studio? I know this question kind sound a bit silly but I have been using Visual Studio for making SSIS Packages, and altought I knew it can be set up for work with code (python, R, you name it) I never used it this way (mainly because I use Rstudio for R and Jupyter notebooks or Spyder for Python). Maybe a video comparing the two idles?
Also I know that I can use Python with RStudio, maybe in the future I can transition to only one idle, and just use Visual Studio.

mabenba
Автор

Hello 👋 there, now I've been following you a great deal you can tell by email as I am also subscribed for the daily updates.

I have made it my goal to become even one proficient in R and also pick up machine Learning. However, I am now finding myself somewhat limited by my machine (laptop). [2015 surface book ]

I know I am pushing it over here, this is not the sort of thing you do. But if you had to recommend a machine, I noticed you use a MacBook. Would you reckon the new MacBook air m2 should do it? It's affordable and would be a step up for me to much more competent machine that's up to the task.

My current machine turns on the fans when putting together a simple ggplot graph. It's embarrassing honestly.

humphreyhanson