Import a dataset with some (fake) genetic information about Penguins:
library(readr)
genetics_tbl <- read_csv("./data/penguin_genetic_diversity.csv")
Rows: 3 Columns: 5── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
chr (2): species, photo
dbl (3): haplotype_div, nucleotide_div, tajima_d
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
genetics_tbl
We can join these columns to the Palmer Penguins dataset:
library(palmerpenguins)
library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
penguins %>%
left_join(genetics_tbl, by = "species") %>%
head()
We begin by importing the January 2050 projected daily minimum and maximum temperature for Sacramento:
sac_temps_tbl <- read_csv("./data/sacramento_daily_temp_jan2050.csv")
Rows: 248 Columns: 6── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
chr (4): clim_var, period, gcm, scenario
dbl (1): temp_f
date (1): dt
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
sac_temps_tbl %>% head()
Convert from a long to wide format:
library(tidyr)
sac_temps_tbl %>%
pivot_wider(names_from = clim_var, values_from = temp_f) %>%
head()
Compute the daily temperature range:
sac_temps_tbl %>%
pivot_wider(names_from = clim_var, values_from = temp_f) %>%
mutate(diurnal_range_f = tasmax - tasmin) %>%
head()