An introductory eco-data science course for R markdown
Before we get to play with R markdown, we need to make sure you have the latest versions of R and R Studio. Then, I’ll give a list of basic R packages that we will use, and then some instructions on how to download the materials in this repository (the stuff you see above).
Although it may seem like a lot, it is important that you follow these instructions. This will reduce the chances of running into errors during the workshop, and will help us get through the material. It will not take more than 5 minutes, but make sure you do it well in advance of the workshop. We don’t want surprises right before we start, do we?
Remember that R and R Studio are two separate things. For now, let’s say R is the engine that runs the code, and R Studio is the IDE (Integrated Development Environment… which is a fancy User Interface) that allows you to interact with R.
sessionInfo()
to see which version of R you have. You should be running on R version 3.4.2 or later. In my case, typing that looks like this, and I am only interested in the first line:Type:
sessionInfo()
You get:
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
... some other technical stuff follows this
Help/Check for Updates
As you will see later, we will need some R packages to do some of the things with R Markdown. By now, I assume that you have the latest version of R and R Studio, and you should not run into any problems.
The basic packages we will need are:
rmarkdown
: Dynamic Documents for Rstargazer
: Well-Formatted Regression and Summary Statistics Tablesknitr
: A General-Purpose Package for Dynamic Report Generation in RkableExtra
: Construct Complex Table with ‘kable’ and Pipe SyntaxTo install them, one by one, copy-paste the following lines of code into your console and hit “Enter”. You want to wait for a package to finish installing before you install the next one just to make sure there are no problems, This will also make it easier to troubleshoot anything on a a package-by-package basis. This might take a couple of minutes, but be patient.
install.packages("rmarkdown")
install.packages("stargazer")
install.packages("knitr")
install.packages("kableExtra")
Clone or Download
If you think you want to get a head start on R markdown, that is great! Here are some links you might find interesting to start playing with this.