Intro to coding in R
Introduction:
Most ecologists analyze their data in the programming language R. Part of the scientific process is analyzing and interpreting the data you collected. In this section, I'm including some resources for learning how to code in R and best practices for analyzing your data.
Why not Python?
Many ecologists use R, but not all. Some ecologists use python (mainly bioinformaticians or those who write large simulations) or matlab (mainly theoreticians). I think R is preferred within ecology because it is easy to organize and query medium-sized datasets (usually data isn't large enough to use a language optimized for querying databases like SQL), running statistical analyses with easily-referenced packages, and making nice graphics.
How to install R and RStudio:
Installing R:
Download R: Choose 1 to download (doesn't matter which one)
Download and install RStudio: This is an IDE for using R
See my video about how to install R and RStudio: https://youtu.be/d-sEdgdduFc
Callie's Resources:
I've made a variety of resources for learning R, mainly geared towards students in Stanford's BIO 47 course (Introduction to Research in Ecology and Evolution). Please see below links to videos.
R for Beginners:
R for Just beyond-beginners:
Click this to see the knitted demo .Rmd file for the R Markdown, dplyr, and ggplot2 videos.
Non-Callie Resources:
Beginner resources:
If you are learning R for the first time, I would strongly suggest using the EdX course (bolded).
Interactive tutorials:
Interactive tutorial in R (Swirl)
Online Courses:
EdX Course * Key sections in EdX course:
1.2 R Basics
1.3 Data Types
3.2 Basic Data Wrangling
3.3 Basic Plots
Junior-Varsity resources:
Software carpentry: Programming with R
Software carpentry: R for Reproducible Scientific Analysis
Ecology-specific resources:
Data Carpentry Workshop: Data analysis and visualization in R for Ecologists (uses dplyr/ggplot)
Tidyverse:
Intro to ggplot2 (making plots)
Intro to dplyr (organizing data)
Learning tidyverse with the Women in Parliment dataset
Learning with gganimate
Textbooks:
Making graphics:
Grammar of Graphics textbook (requires SUNet ID to download)
Introduction to Graphics in R from Modern Statistics for Modern Biology
Quick visualization using equisse
Using RMarkdown:
I write scripts and document code using RMarkdown. RMarkdown helps generate reproducible and easy-to-follow documentation of analyses, output, and code. See my RMarkdown video above!
Fun stuff:
Advanced resources:
Using Bioconductor:
Microbiome analyses:
RNASeq:
Teaching R:
Advanced R graphics:
Using Git in RStudio:
Nice tutorial from Data Carpentr