Dan Ovando Profile picture
24 Sep, 10 tweets, 8 min read
Fall is here and a lot of students are starting their journey as #rstats users. This can be tough, especially with all the barriers to learning that 2020 is throwing at us. Here are some tips (almost all from @JennyBryan!) I wish I’d followed from the start of my #rstats career
Beginning #rstats users sometimes focus on the mechanics of R and don’t get around to establishing some best practices that will set you up for writing more efficient and reproducible code. These all will make your life easier in the long run, I promise! #openscience
1. Develop a project-oriented workflow. Decide on a common file structure and stick with it for every project. Here’s what I use, based on this great paper journals.plos.org/ploscompbiol/a…. That way, you always know where to find files in any project Image
2. Purge setwd from your #rstats code! Using #rstudio projects with project-oriented workflows ensures your working directory is correct and that your code will work for future you and your collaborators without using setwd (from @JennyBryan) tidyverse.org/blog/2017/12/w… Image
3. Get rid of hard-coded file paths! read.csv(“~/my/computer/data/data.csv”) will only work on your current computer . Using read.csv(here::here(“data”,”data.csv”)) will work for future you and collaborators on any platform github.com/r-lib/here ( @allison_horst ) Image
4. Use a version control system like git + GitHub. It’s great for collaboration & reproducibility, and having a time machine for your code when you inevitably break everything night before a major deadline is a game changer. happygitwithr.com
5. Manage package dependencies with renv. We’ve all been there: you decide to update packages and suddenly your code for tomorrow’s deadline is broken! renv helps you and your collaborators manage package versions to keep things running smoothly rstudio.github.io/renv/articles/…
6. Pick a style guide and stick with it. e.g. I use snake_case since it reads well, avoids confusing case-sensitive variable names, and is easy to program with. e.g. finding and saving all objects that end with “_plot" is super easy style.tidyverse.org
7. Make friends with #rmarkdown. You put a lot of time and effort into #rstats homework. Doing them in R Markdown means that you can easily reproduce your steps when you want to actually put what you learned into practice someday down the road rmarkdown.rstudio.com/lesson-1.html
8. Check out the great materials at @openscapes by @juliesquid and @ecodatasci for other helpful tips on creating open and reproducible science using #rstats #ropensci openscapes.org eco-data-science.github.io

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Dan Ovando

Dan Ovando Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!