appliedepi.bsky.social
@appliedepi.bsky.social
Improving Applied Epidemiology worldwide. Increasing the knowledge and resources of Epidemiologists no matter who or where they are.

Creator of the EpiRHandbook: https://epirhandbook.com/
“I’ve taken several R trainings - this is the BEST!”
📢 New courses posted! Intro to R for public health
🗓️ 40 hours part-time, synchronous, with unlimited 1-on-1 coaching and options for ALL time zones.
✏️ Register: appliedepi.org/training/pub...
March 13, 2025 at 9:52 AM
📢 Last week to apply for the Applied Epi scholarships!

Transition your team to R with free or discounted courses and services.

Why apply?
✔️ Full or partial scholarships
✔️ Focused on strengthening public health capacity

🗓️ Apply by Feb 10, 2025! 🌐 appliedepi.org/training/scholarships-ae
February 3, 2025 at 8:51 PM
🚨 Applications are NOW OPEN for Applied Epi’s 2025 scholarships! 🚨

💡 For teams in low- & middle-income countries working in epidemiology, this is your chance to access funding for courses and support services that help transition to R.

🗓️ Deadline: Feb 10, 2025
🌐 Apply here: appliedepi.org
January 21, 2025 at 1:22 AM
🎉 R scholarship applications open on January 20!

If your team (government or nonprofit) works in applied epidemiology in a low- or middle-income country, you could get access to our Intro to R course and Support Desk! Details: appliedepi.org/training/sch...
#Rstats #epitwitter
January 17, 2025 at 5:04 PM
Repeatedly rerunning the code is quite fun
December 24, 2024 at 8:57 PM
And how did we get Santa's coordinates?

Since he didn't share his location, we created a function (get_random_night_coords()) to randomly generate coordinates of a location with a current local time between 11pm and 3am, assuming those are his working hours!

Close enough!
December 24, 2024 at 8:57 PM
Both of these figures are created with ggplot2, and use a saved PNG file of Santa.

geom_image() from {ggimage} places the image at specified coordinates, reading from the file path.

Here's the ggplot code for the second figure:
December 24, 2024 at 8:57 PM
And if you want his current location:
December 24, 2024 at 8:57 PM
🎄 Merry Christmas Eve, everyone! 🎄

To wrap up this advent calendar, here’s our final tip:

Did you know you can use your own images in ggplot?

Check out this festive example with a cartoon of Santa —on his (surprisingly inefficient?) route tonight! 🎅✨

#DataViz #RStats
December 24, 2024 at 8:57 PM
Today's post is for anyone with bdays this time of the year. We see you!

This includes our Exec Director, an expert in "combo Xmas/bday" presents! Happy birthday Neale! 🎂

On that note, ever work with multiple date columns but need to pick one? Use coalesce() to easily prioritize a value!

#Rstats
December 23, 2024 at 8:38 PM
Here's the code if you like the "minimalist" aesthetic.

That said, it does show the versality of ggplot!
December 22, 2024 at 9:25 PM
P.s. Before finding the {christmas} package I was ready to make this the main event for this post:
December 22, 2024 at 9:25 PM
🎄Day 22: An R Christmas Tree 🎄

There's still time to write your Christmas cards!

And what better captures the yuletide spirit than...R...

Seriously though, check out the {christmas} package by Jose Barrera-Gomez.. Stunning!
December 22, 2024 at 9:25 PM
Want to further customize colours? 🎨

The example above uses the same colour palette for each plot, with scale_fill_brewer().

For custom colours, you can also define a palette inside scale_fill_manual() - or as a separate object that you refer to (as discussed yesterday).
December 22, 2024 at 12:24 AM
🎄Day 21: Ggplot efficiency part 3🎄

Need many plots with the same style/formatting but slightly different inputs?

💡Create a custom ggplot function!

Define your plot upfront in the function, with all the long formatting code. Then run the function for each new plot with different inputs.
December 22, 2024 at 12:24 AM
🎄Day 20: Ggplot efficiency: part 2 🎄

Visualizing the same variables in different ways (e.g. sex by time/place)?

💡Tip: Easily standardize colour palettes by defining them once at the start of your code.

Then reuse the palettes within scale_fill_manual() or scale_color_manual() across plots.
December 21, 2024 at 3:31 AM
If you want to reset, you can define theme_set() as theme_gray(), which is the default ggplot theme.

Or, restart your R session.
December 20, 2024 at 1:27 AM
🎄Day 19: Ggplot efficiency: part 1🎄

Do you need a consistent plot style for a document?

Try theme_set()🎨

Define the look of fonts, grid lines, backgrounds, axis text etc once inside theme_set(). This will apply to all subsequent ggplots in your R session. No need for long theme() code per plot!
December 20, 2024 at 1:27 AM
🎄Day 18 🎄

Having a rough day?

The {praise} package is there for you.

Go on, give praise() a whirl.... ♥️
December 18, 2024 at 10:13 PM
And finally, here's a neat way to copy code to just above or below the original.

Highlight code and then press:

🪟 Shift + Alt + Up/Down (Windows)
🍎 Option + Command + Up/Down (Mac)
December 17, 2024 at 12:27 PM
Or try moving code up and down your script easily.

Do this by highlighting code and then:

🪟 Alt + Up/Down (Windows)
🍎 Option + Up/Down (Mac)
December 17, 2024 at 12:27 PM
🎄Day 17: RStudio magic🎄

Want to be in multiple places at once over the holidays?

We can't help you with that.

But - we can show you how to type in multiple places at once in RStudio! 😮

Useful when you need to make the same edit across your code but Find + Replace isn't suitable.
December 17, 2024 at 12:27 PM
To make "ñ" and "ñ" equal in R, you can normalize their Unicode forms using the {stringi} package, with the stri_trans_nfc() function.
December 15, 2024 at 11:09 PM
🎄Day 14: Quiz!🎄

Why do these two seemingly identical characters not equal each other in R?
December 15, 2024 at 2:17 AM
🎄Day 12: Assessing missing data🎄

Epis know well that missingness can skew analyses, so needs careful review. No fear, {naniar} can help! E.g.:

☑️pct_miss_case(): to check % of rows with NAs
☑️gg_miss_var(): to quickly visualize missingness by column

See more in Ch. 20 of the EpiRHandbook.com!
December 12, 2024 at 10:07 PM