knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "75%" )
The goal of rcaladapt is to access climate data from Cal-Adapt, including historical and projected climate data for specific coordinates.
You can install the development version of rcaladapt from Github with:
devtools::install_github("kdybala/rcaladapt")
Extract projected annual precipitation for the RCP 4.5 scenario, from the HadGEM2-ES model, for specific coordinates:
library(rcaladapt) example1 <- query_caladapt(var = 'pr', scenario = 'rcp45', model = 'HadGEM2-ES', coords = '-122.545886,38.248392') # convert from inches/day to inches/yr example1$data <- example1$data * 365 head(example1)
The function returns a tibble, to facilitate further analysis and plotting:
library(ggplot2) ggplot(example1, aes(index, data)) + geom_line() + xlab('Year') + ylab('precipitation (in/yr)')
Use purrr::map functions to repeat for several climate models, scenarios, or variables:
models <- c('HadGEM2-ES', 'CNRM-CM5', 'CanESM2', 'MIROC5', 'livneh') example2 <- purrr::map_dfr(models, .f = function(x) { query_caladapt(var = 'tasmin', scenario = 'rcp85', model = x, coords = '-122.545886,38.248392') }) ggplot(example2, aes(index, data)) + geom_line(aes(color = model)) + ylab('Minimum Temperature (F)') + xlab('Year')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.