Introduction

Welcome to the Jornada Environmental Data Science education site (JEDS!). Our aim is to teach introductory and intermediate elements of data science (data management, analysis, statistics, visualization, etc.) to Jornada researchers using open-source software tools, and real data from the Jornada.

Setup for an R lesson

Many JEDS tutorials use the R programming language, and additional packages from the R software ecosystem, as the primary software tools, especially for statistical analysis. During R-based JEDS workshops we teach using the RStudio development environment as our primary programming and analysis environment. For working through these tutorials, either on your own or in a workshop, you should have both installed according to the instructions below.

The section below borrows heavily from the “Data Carpentry: Data Analysis and Visualization in R for Ecologists” lesson (Eunice, 2022)

If the computer is managed by their organization’s IT department they might need help from an IT administrator.

Install R and RStudio

R and RStudio are two separate pieces of software:

  • R is a programming language and software used to run code written in R.
  • RStudio is an integrated development environment (IDE) that makes using R easier. In this course we use RStudio to interact with R.

If you don’t already have R and RStudio installed, follow the instructions for your operating system below. You have to install R before you install RStudio.

For Windows

For MacOS

For Linux

Update R and RStudio

If you already have R and RStudio installed, first check if your R version is up to date:

The changes introduced by new R versions are usually backwards-compatible. That is, your old code should still work after updating your R version. However, if breaking changes happen, it is useful to know that you can have multiple versions of R installed in parallel and that you can switch between them in RStudio by going to Tools > Global Options > General > Basic.

While this may sound scary, it is far more common to run into issues due to using out-of-date versions of R or R packages. Keeping up with the latest versions of R, RStudio, and any packages you regularly use is a good practice.

Install required R packages

During the course we will need a number of R packages. Packages contain useful R code written by other people. In most workshops we will use the packages tidyverse, nlme, lme4, emmeans, and ratdat.

To install these packages, open RStudio and copy and paste the following command into the console window (look for a blinking cursor on the bottom left), then press the Enter (Windows and Linux) or Return (MacOS) to execute the command.

install.packages(c("tidyverse", "nlme", "lme4", "emmeans", "ratdat"))

Alternatively, you can install the packages using RStudio’s graphical user interface by going to Tools > Install Packages and typing the names of the packages separated by a comma.

R tries to download and install the packages on your machine. When the installation has finished, you can load the packages by pasting the following code into the console:

library(tidyverse)
library(nlme)
library(lme4)
library(emmeans)
library(ratdat)

If you do not see an error like there is no package called ‘...’ you are good to go!

NOTE that if you are attending a workshop, you will likely receive additional instructions about packages required for for your workshop. It is a good idea to install these in advance, using commands like those above, and let your instructors know if you have any problems.

If you do not see an error like there is no package called ‘...’ you are good to go!

Updating R packages

Generally, it is recommended to keep your R version and all packages up to date, because new versions bring improvements and important bugfixes. To update the packages that you have installed, click Update in the Packages tab in the bottom right panel of RStudio, or go to Tools > Check for Package Updates...

You should update all of the packages required for the lesson, even if you installed them relatively recently.

Sometimes, package updates introduce changes that break your old code, which can be very frustrating. To avoid this problem, you can use a package called renv. It locks the package versions you have used for a given project and makes it straightforward to reinstall those exact package version in a new environment, for example after updating your R version or on another computer. However, the details are outside of the scope of this lesson.

A copy of all data files used in these lessons are stored in the data/ directory of the GitHub repository. The data files you need for lessons will be specified at the start of the lesson materials, and you may also receive additional information from instructors before for workshops.

Setup for shell, git and GitHub lessons

git is a distributed version control system and is the underlying technology behind GitHub, the web-based software development and collaboration platform. It is common to use git together with a “shell”, which is a command-line interface to your computer. So, for JEDS tutorials that involve git and GitHub, please complete three steps using the recommended resources:

  1. Install git to your computer
  2. Make sure you have access to a shell
  3. Sign up for a GitHub account

If you are on MacOS or Linux, you should have a shell installed already, just make sure you can open it. For Windows you can install git and the bash shell together. There are two good resources for getting git and related software ready for a one of the JEDS tutorials.

If you want, you can also install a GUI client for git to help visualize and manage what is happening with repositories you are working with. A few recommended clients are GitKraken, SourceTree, and GitHub Desktop. More discussion of clients is available over at Happy Git with R.

Preparing for JEDS workshops

These workshops are based on “live coding,” so instructors will be running example R code while learners are expected to follow along on their own machine. To follow along successfully during a JEDS workshop, please ensure you have a laptop or other Windows, MacOS, or Linux device that has R and RStudio, and any necessary R packages, installed and up to date. Look for instructions provided by instructors in advance of the workshop about what R packages to install, and any other materials you may need to download or bring. Also, always bring a charger for your device.

If the workshop is in a virtual format we will be using the Zoom platform, so make sure you have Zoom installed and up-to-date on your machine as well.