I’m not the first to write about this, nor will I be the last, but I think it’s worth passing on some general concepts in the plainest possible terms here. What I chose to include is based on conversations with newer R users who may not have any coding experience prior to using the language for a non-computational field of study. So, here are some things to know, without getting too far into the technical weeds (read: I will try to use as little jargon as possible).
I’m going to skip how to learn coding R, because many have already written about that. Here’s where I’m going to skip ahead to: let’s assume you have RStudio installed, and you write your first script, with the goal that it will be useful to you more than once (what a concept)! Your goal is to write something that, given maybe input changes from run to run, will run from start to finish and regenerate any of the desired output. The way to run a script “head to toe” is to click the “Source” button in the upper left pane of RStudio. You want to write scripts that can be sourced, because it means then you’ve codified every step of your process, such that it can be reproduced (hey, that sounds like something in line with the scientific method)! Congratulations, you’re on your way to doing better science already!