2 First Steps
2.1 Why R
We focus on R because it is good for complex stats, concise figures, and coherent organization. It is built and developed by applied statisticians for statistics, and used by many in academia and industry. For students, think about labor demand and what may be good for getting a job. Do some of your own research to best understand how much to invest.
2.2 Install R
First Install R. Then Install Rstudio.
For help setting up, see any of the following links
- https://learnr-examples.shinyapps.io/ex-setup-r/
- https://rstudio-education.github.io/hopr/starting.html
- https://a-little-book-of-r-for-bioinformatics.readthedocs.io/en/latest/src/installr.html
- https://cran.r-project.org/doc/manuals/R-admin.html
- https://courses.edx.org/courses/UTAustinX/UT.7.01x/3T2014/56c5437b88fa43cf828bff5371c6a924/
- https://owi.usgs.gov/R/training-curriculum/installr/
- https://www.earthdatascience.org/courses/earth-analytics/document-your-science/setup-r-rstudio/
Make sure you have the latest version of R and Rstudio for class. If not, then reinstall.
2.3 Interfacing with R
Rstudio is easiest to get going with. (There are other GUI’s.) There are 4 panes. The top left is where you write and save code
- Create and save a new
R Script
file My_First_Script.R - could also use a plain .txt file.
The pane below is where your code is executed. For all following examples, make sure to both execute and store your code.
Note that the coded examples generally have objects, functions, and comments.
2.4 Introductions to R
There are many good and free programming materials online.
The most common tasks can be found https://github.com/rstudio/cheatsheets/blob/main/rstudio-ide.pdf
Some of my programming examples originally come from https://r4ds.had.co.nz/ and I recommend https://intro2r.com. I have also used online material from many places over the years, including
- https://cran.r-project.org/doc/manuals/R-intro.html
- R Graphics Cookbook, 2nd edition. Winston Chang. 2021. https://r-graphics.org/
- R for Data Science. H. Wickham and G. Grolemund. 2017. https://r4ds.had.co.nz/index.html
- An Introduction to R. W. N. Venables, D. M. Smith, R Core Team. 2017. https://colinfay.me/intro-to-r/
- Introduction to R for Econometrics. Kieran Marray. https://bookdown.org/kieranmarray/intro_to_r_for_econometrics/
- Wollschläger, D. (2020). Grundlagen der Datenanalyse mit R: eine anwendungsorientierte Einführung. http://www.dwoll.de/rexrepos/
- Spatial Data Science with R: Introduction to R. Robert J. Hijmans. 2021. https://rspatial.org/intr/index.html
What we cover in this primer should be enough to get you going. But there are also many good yet free-online tutorials and courses.
- https://www.econometrics-with-r.org/1.2-a-very-short-introduction-to-r-and-rstudio.html
- https://rafalab.github.io/dsbook/
- https://moderndive.com/foreword.html
- https://rstudio.cloud/learn/primers/1.2
- https://cran.r-project.org/manuals.html
- https://stats.idre.ucla.edu/stat/data/intro_r/intro_r_interactive_flat.html
- https://cswr.nrhstat.org/app-r