Learning Objectives

  • understand and explain why coding is advantageous for data management
  • learn principles to format R code for readability and clarity
  • practice adding comments and breaks to R code
  • call R scripts from within R scripts (sourcing)
  • properly organize an R project and workspace with RStudio
  • read and write tables

Day 1: Intro to R and Rstudio

Review

Intro

Knowing your way around R and Rstudio

Expressions and variables/objects

Rstudio projects

Exercise: the README file

Basics of functions

A minute feedback for class 5



Day 2: Intro to vectors

Review

Basics of Vectors

1 == 1
1 == 2
1 != 2
1 > 2
1 > 1
1 >= 1
1 < 2
1 <= 2
"A" == "A"
"A" == "a"
"A" != "a"

Do Basic Vectors.

Null values

count_na <- c(9, 16, NA, 10)
mean(count_na)
mean(count_na, na.rm = TRUE)

Working with multiple vectors

states <- c("FL", "FL", "GA", "SC")
count <- c(9, 16, 3, 10)
area <- c(3, 5, 1.9, 2.7)

Vector math

density <- count / area

Filtering

density[states == 'FL']
density[states != 'FL']
states[density > 3]
states[density < 3]
states[density <= 3]
density[density > 3]

Homework: Do Shrub Volume Vectors exercise.

A minute feedback for class 6