Plotting posts
The HealthyR advent calendar is based on “R for Health Data Science” by Harrison and Pius. Use JKL20 for 20% off, including free worldwide shipping.
🌟 Day 05 – Plotting continuous (numeric) data🌟
— Riinu Pius (@_Riinu_) December 5, 2022
Can't go wrong with a histogram or box plot. Overlay the latter with actual data points if can!
Any questions happy to answer! @ewenharrison#HealthyR #rstats: "R for Health Data Science" 📖 chapter:https://t.co/oSVOORfGKt pic.twitter.com/LyzMa9OGaU
🌟 Day 06 – Legend position🌟
— Riinu Pius (@_Riinu_) December 6, 2022
You've got options: left, right, top, bottom, or none!
Or use relative coordinates:
legend.position = c(0.85, 0.1)
Any questions happy to answer!@ewenharrison#HealthyR #rstats: "R for Health Data Science" book chapter:https://t.co/At0O9K1kF2 pic.twitter.com/GOuBRZtal7
🌟 Day 07 – Legend columns🌟
— Riinu Pius (@_Riinu_) December 7, 2022
A minor change but can be useful if you're squeezed for space!
Any questions: @ewenharrison and myself happy to answer here!#HealthyR #rstats: "R for Health Data Science" book chapter:https://t.co/At0O9K1kF2 pic.twitter.com/nSh9IUGr38
🌟 Day 08 – Combine plots with patchwork🌟
— Riinu Pius (@_Riinu_) December 8, 2022
1️⃣Save your plots into objects (e.g., p1, p2)
2️⃣library(patchwork): https://t.co/WP2AM2G2uS
3️⃣combine with just +, or try | () / for various layouts#HealthyR #rstats: "R for Health Data Science" book chapter:https://t.co/dssBc63Kzv pic.twitter.com/mlf2bpfdIL
🌟Day 09 – Bar plots: geom_bar() or geom_col()?!?🌟
— Riinu Pius (@_Riinu_) December 9, 2022
📊Use geom_bar to count up (patient-level) data
📊Use geom_col for summarised data - if you have a numeric y
Or if one doesn’t work try the other 😜#HealthyR #rstats "R for Health Data Science":https://t.co/X5ix6Xge1H pic.twitter.com/PkXwhyUEU6
🌟Day 10 – Set a theme for all your plots🌟
— Riinu Pius (@_Riinu_) December 10, 2022
Today’s #HealthyR #rstats tip is short and sweet:
theme_set(theme_bw())
at the top of your script will apply on everything you make!
This and more freely available in “R for Health Data Science” 📖: https://t.co/vaQJC6J7aG pic.twitter.com/msV0bOM60b
🌟Day 11 – fct_reorder() + ggplot() = 💙🌟
— Riinu Pius (@_Riinu_) December 11, 2022
Use fct_reorder() to get Y-axis countries ordered by another variable - cool plot with just a couple of lines of code 🙌📈
“R for Health Data Science” 📖#HealthyR #rstats:https://t.co/18s80BnoLn pic.twitter.com/W5WGNJZkZU
HealthyR: R for Health Data Science book and resources: https://healthyr.surgicalinformatics.org/