Vectors

sites <- c("a", "a", "b", "c")
length(sites)
density_ha <- c(2.8, 3.2, 1.5, 3.8)
mean(density_ha)
max(density_ha)
min(density_ha)
sum(density_ha)

Do Bird Banding 1-4.

Null values

density_ha <- c(2.8, 3.2, 1.5, NA)
mean(density_ha)
mean(density_ha, na.rm = TRUE)

Working with multiple vectors

density_ha <- c(2.8, 3.2, 1.5, 3.8)
area_ha <- c(3, 5, 1.9, 2.7)
total_number <- density_ha * area_ha
area[sites == 'a']
area[sites != 'a']
sites[area_ha > 3]
sites[area_ha >= 3]
sites[area_ha < 3]
sites[sites != 'a']

Do Shrub Volume Vectors 1-3.

Data frames

surveys <- data.frame(sites, density_ha, area_ha)

Reading in external data

shrub_data <- read.csv('https://datacarpentry.org/semester-biology/data/shrub-dimensions-labeled.csv')

Factors

str(shrub_data)
shrub_data <- read.csv('https://datacarpentry.org/semester-biology/data/shrub-dimensions-labeled.csv', stringsAsFactors = FALSE)
str(shrub_data)

Start Shrub Volume Data Frame, but just use the url instead of downloading the file.