Example R Code

Here is an example of R code, and a hypothetical data set, that will introduce you to using R to accomplish some fundamental data tasks. In particular, note in the code:

1) Use of “#” to insert comments into the code,

2) Use of “library” to load packages that the program uses,

3) Use of the assignment operator “<-” to create R objects,

4) Different ways of referencing a variable depending on whether you are using a Base R approach (look for the “$”) or a Tidyverse approach (look for the “%>%”, which is called the “pipe” and which is read as “… and then …”),

5) Some examples of basic data analysis, and

6) Some examples of basic graphs.