These materials are intended for an audience new to coding. They take users from setting up a project in R to data manipulation with dplyr
and graphing with ggplot2
. I opted for .R files instead of .Rmd based on the philosophy that seeing pure code is easier to process than code + markdown formatting at the same time. The full contents are as follows:
- Why should we code?
- Setting up a project and organizing files
- R as a calculator
- Variable assignment
- Control flow: if/else
- Control flow: for/while
- Functions
- Coding best practices
- Installing and attaching packages
- Loading datasets
- Data manipulation with
dplyr
- Statistical analyses: t-tests, linear and logistic regression
- Graphing with
ggplot2
- Troubleshooting advice
Before using these materials, you should download both R and RStudio. Briefly, R is the programming language itself and RStudio is software that makes it easier to code in R and organize your files.
Download R first, then RStudio.
Links for downloading R:
- For Mac users: https://cran.r-project.org/bin/macosx/
- For Windows users: https://cran.r-project.org/bin/windows/
Link for downloading RStudio: https://posit.co/download/rstudio-desktop/
This is not an exhaustive list of additional resources, but provides some immediately useful materials following the content of the two introductory sessions.
- Coding style conventions: http://adv-r.had.co.nz/Style.html
- A lot more about using R: https://r4ds.hadley.nz/
- Advanced graphing: https://www.yan-holtz.com/PDF/Ggplot2_advancedTP_correction.html
- Graph gallery (good for inspiration or examples of new graphs): https://r-graph-gallery.com/