library(dplyr)
library(terra)
library(readxl)
library(kableExtra)
library(purrr)
library(sp)
library(tibble)
5 Rain Gauges vs Gridded Precipitation Analysis
5.1 Library
We utilize the terra package for rasters (Hijmans 2024). The package KableExtra is for table visualizations(Hao Zhu 2024). The sp package is used for calculating distances (Pebesma and Bivand 2005). Packages purr and tiblle are for data wrangling Müller and Wickham (2023)
Read in files for the analysis
setwd("C:/Users/Vicente/repo/ClimatePanama/ClimatePanamaBook")
# Read in the data
<- read.csv("../tables/precipitation.csv")
data_ground<- read.csv("../tables/stri_met_stations.csv")
striStation<- read.csv("../data_ground/met_data/ACP_data/cleanedVV/ACP_met_stations.csv")
acpStation
#Global variables
<- terra::ext(c(-80.2,-79.4, 8.8, 9.5)) extentMap
5.2 Functions
<- function(minyear,maxyear,data){
calculate_climatology<- data %>%
climatology::select(year,site,annual,jfma)%>%
dplyrfilter(year>=minyear&year<=maxyear)%>%
group_by(site)%>%
summarize(annual=mean(annual,na.rm=TRUE),
jfma=mean(jfma,na.rm=TRUE))
return(climatology)
}
<-function(list,extent){
annual_pan<-terra::rast(list)
b<-terra::app(b,sum)
c<-terra::crop(c,extent)
dreturn(d)
}
<- function(list, extent) {
jfma_pan <- terra::rast(head(list, 4))
b <- terra::app(b, sum)
c <- terra::crop(c, extent)
d return(d)
}
<- function(raster_object, coordinate) {
find_nearest_non_na <- which(!is.na(terra::values(raster_object)))
non_na_cells <- xyFromCell(raster_object, non_na_cells)
non_na_coords <- sp::spDists(x = matrix(coordinate, nrow = 1), y = non_na_coords, longlat = TRUE)
dists <- non_na_cells[which.min(dists)]
nearest_cell return(terra::values(raster_object)[nearest_cell])
}
<- function(list_object, coordinate) {
extract_land <- numeric(nrow(coordinate))
result for (i in seq_len(nrow(coordinate))) {
<- terra::extract(list_object, coordinate[i, ], na.rm = FALSE)[1,2]
extracted_value <- ifelse(is.na(extracted_value), find_nearest_non_na(list_object, as.matrix(coordinate[i, ])), extracted_value)
result[i]
}return(result)
}
<- function(raster_object, coordinate) {
find_nearest_non_na_id <- which(!is.na(terra::values(raster_object)))
non_na_cells <- xyFromCell(raster_object, non_na_cells)
non_na_coords <- sp::spDists(x = matrix(coordinate, nrow = 1), y = non_na_coords, longlat = TRUE)
dists <- non_na_cells[which.min(dists)]
nearest_cell return(nearest_cell)
}
<- function(list_object, coordinate) {
extract_row_column <- character(nrow(coordinate)) # Use character vector to store "row,col"
result for (i in seq_len(nrow(coordinate))) {
<- terra::extract(list_object, coordinate[i, ], na.rm = FALSE)[1, 2]
extracted_value <- terra::extract(list_object, coordinate[i, ], na.rm = FALSE,cells=TRUE)[1,3]
extracted_id
<- ifelse(is.na(extracted_value), find_nearest_non_na_id(list_object,as.matrix(coordinate[i,])), extracted_id)
result[i]
}return(result)
}
#stats calculation
<-function(predicted,observed){
stats<-cor.test(observed,predicted)$estimate
correlation<-sqrt(mean((predicted-observed)^2 , na.rm = TRUE ) )
rmse<- mean((predicted-observed),na.rm=TRUE)
bias<- mean(abs(predicted-observed), na.rm = TRUE)
mae<-c(correlation,rmse,bias,mae)
donereturn(done)
}
List of data sets, their temporal extents and the location of the climatology tiffs for each of them
<- list(
datasets_info list(start_year = 1979, end_year = 2013, dataset_name = "CHELSA 1.2",column_name="CHELSA1.2", temporal = "1979-2013",path = "../data_reanalysis/CHELSA 1.2/"),
list(start_year = 1981, end_year = 2010, dataset_name = "CHELSA 2.1",column_name="CHELSA2.1", temporal = "1981-2010", path = "../data_reanalysis/CHELSA 2.1/"),
list(start_year = 2003, end_year = 2016, dataset_name = "CHELSA EarthEnv",column_name="CHELSA_EarthEnv", temporal = "2003-2016",path = "../data_reanalysis/CHELSA EarthEnv/climatology"),
list(start_year = 1980, end_year = 2009, dataset_name = "CHPclim",column_name="CHPclim", temporal = "1980-2009", path = "../data_reanalysis/CHPclim/"),
list(start_year = 1970, end_year = 2000, dataset_name = "WorldClim 2.1",column_name="WorldClim2.1", temporal = "1970-2000", path = "../data_reanalysis/WorldClim 2.1"),
list(start_year = 1981, end_year = 2016, dataset_name = "CHIRPS 2.0",column_name="CHIRPS2.0",temporal = "1981-2016", path = "../data_reanalysis/CHIRPS 2.0/climatology"),
list(start_year = 1979, end_year = 2016, dataset_name = "CHELSA-W5E5v1.0",column_name="CHELSAW5E5v1.0", temporal = "1979-2016",path = "../data_reanalysis/CHELSA-W5E5v1.0/climatology"),
list(start_year = 1981, end_year = 2010, dataset_name = "TerraClimate",column_name="TerraClimate", temporal = "1981-2010", path = "../data_reanalysis/TerraClimate"),
list(start_year = 1979, end_year = 2013, dataset_name = "PBCOR CHELSA 1.2",column_name="PBCOR_CHELSA1.2", temporal = "1979-2013", path = "../data_reanalysis/PBCOR/CHELSA 1.2 corrected"),
list(start_year = 1980, end_year = 2009, dataset_name = "PBCOR CHPclim",column_name="PBCOR_CHPclim", temporal = "1980-2009", path = "../data_reanalysis/PBCOR/CHPclim corrected"),
list(start_year = 1970, end_year = 2000, dataset_name = "PBCOR WorldClim 2.1",column_name="PBCOR_WorldClim2.1", temporal = "1970-2000", path = "../data_reanalysis/PBCOR/WorldClim corrected")
)
5.3 Climatologies
Loop through each dataset and calculate climatology
<- datasets_info %>%
climatologies map_df(function(info) {
calculate_climatology(info$start_year, info$end_year, data_ground) %>%
mutate(source = info$dataset_name)}) %>%
left_join(acpStation[, c('site', 'latitude', 'longitude', 'Elevation')], by = c("site" = "site")) %>%
left_join(striStation[, c('alias', 'latitude', 'longitude')], by = c("site" = "alias")) %>%
mutate(latitude = ifelse(is.na(latitude.x), latitude.y, latitude.x),
longitude = ifelse(is.na(longitude.x), longitude.y, longitude.x),
longitude = -1 * abs(longitude)) %>%
::select(site, latitude, longitude, source, annual, jfma, Elevation)
dplyr
#extract the values at the coordinates for climatologies
for (source in datasets_info) {
<- list.files(source$path, pattern = "\\.tif$", full.names = TRUE)
files <- annual_pan(files, extentMap)
annual_data $dataset_name]] <- extract_land(annual_data,climatologies[,3:2])
climatologies[[sourcepaste0(source$dataset_name,"_cell")]]<-extract_row_column(annual_data,climatologies[,3:2])
climatologies[[
= jfma_pan(files, extentMap)
jfma_data = paste(source$dataset_name, "_jfma", sep = "")
column_name
= extract_land(jfma_data, climatologies[,3:2])
climatologies[[column_name]]
}
write.csv(climatologies,file="../tables/climatologies.csv")
<- unique(climatologies$source)
sources_unique <- data.frame()
df
for (source in sources_unique) {
<- paste0(source)
data_column <- nrow(unique(climatologies[climatologies$source == source, paste0(source,"_cell")]))
unique_values
# Find sites with the same value
<- climatologies[climatologies$source == source, ] %>%
sites_with_same_value group_by(.data[[paste0(source, "_cell")]]) %>%
filter(n() > 1) %>%
summarize(sites = paste(site, collapse = ", "))
cat(paste("Source:", source, "\n"))
cat(paste(" - Unique raster cell:", unique_values, "\n"))
cat(paste(" - Sites in the same cell:", sites_with_same_value$sites, "\n"))
}
Source: CHELSA 1.2
- Unique raster cell: 30
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
Source: CHELSA 2.1
- Unique raster cell: 30
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
Source: CHELSA EarthEnv
- Unique raster cell: 30
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
Source: CHPclim
- Unique raster cell: 28
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
- Sites in the same cell: CASCADAS, EMPIREHILL
- Sites in the same cell: BALBOAHTS, DIABLO
Source: WorldClim 2.1
- Unique raster cell: 30
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
Source: CHIRPS 2.0
- Unique raster cell: 28
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
- Sites in the same cell: CASCADAS, EMPIREHILL
- Sites in the same cell: BALBOAHTS, DIABLO
Source: CHELSA-W5E5v1.0
- Unique raster cell: 30
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
Source: TerraClimate
- Unique raster cell: 27
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
- Sites in the same cell: EMPIREHILL, HODGESHILL
- Sites in the same cell: BALBOAFAA, BALBOAHTS, DIABLO
Source: PBCOR CHELSA 1.2
- Unique raster cell: 27
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
- Sites in the same cell: CASCADAS, EMPIREHILL
- Sites in the same cell: BALBOAHTS, DIABLO
- Sites in the same cell: CRISTOBAL, GALETASTRI
Source: PBCOR CHPclim
- Unique raster cell: 28
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
- Sites in the same cell: CASCADAS, EMPIREHILL
- Sites in the same cell: BALBOAHTS, DIABLO
Source: PBCOR WorldClim 2.1
- Unique raster cell: 27
- Sites in the same cell: BCI, BCICLEAR, BCIELECT
- Sites in the same cell: CASCADAS, EMPIREHILL
- Sites in the same cell: BALBOAHTS, DIABLO
- Sites in the same cell: CRISTOBAL, GALETASTRI
Compute a results data frame
<- data.frame(
results Source = character(),
Correlation = numeric(),
RMSE = numeric(),
Bias = numeric(),
MAE = numeric(),
stringsAsFactors = FALSE
)<-results
results_jfma
for (i in 1:length(datasets_info)) {
<- datasets_info[[i]]$dataset_name
source <- climatologies[climatologies$source == source,][[source]]
predicted <- climatologies[climatologies$source == source,][["annual"]]
observed <- stats(predicted, observed)
stats_result
<- rbind(results, data.frame(
results Source = source,
Correlation = stats_result[1],
RMSE = stats_result[2],
Bias = stats_result[3],
MAE = stats_result[4],
stringsAsFactors = FALSE
))
}
for (i in 1:length(datasets_info)) {
<- datasets_info[[i]]$dataset_name
source =paste0(source,"_jfma")
column<- climatologies[climatologies$source == source,][[column]]
predicted <- climatologies[climatologies$source == source,][["jfma"]]
observed <- stats(predicted, observed)
stats_result
<- rbind(results_jfma, data.frame(
results_jfma Source = source,
Correlation = stats_result[1],
RMSE = stats_result[2],
Bias = stats_result[3],
MAE = stats_result[4],
stringsAsFactors = FALSE
))
}
#save both results as csv in tables folder
write.csv(results, file= "../tables/spatial_variation_annual.csv")
write.csv(results_jfma, file= "../tables/spatial_variation_jfma.csv")
Tables for visualizations
<-results %>%mutate(Correlation = round(Correlation, 2), RMSE= round(RMSE,0),Bias=round(Bias,0),MAE=round(MAE,0)) %>%
annual_tablerownames_to_column(var = "rowname") %>%
::select(-rowname) %>%
dplyrrename("Gridded Climate Product" = "Source") %>% rename("Mean bias (mm)"="Bias")%>%
kbl(caption = "Spatial variation among 31 sites in total annual precipitation") %>%
kable_classic(full_width = F)
%>%save_kable("../plots/spatial_annual_variation.png",density=900)
annual_table annual_table
Gridded Climate Product | Correlation | RMSE | Mean bias (mm) | MAE |
---|---|---|---|---|
CHELSA 1.2 | 0.79 | 337 | 77 | 267 |
CHELSA 2.1 | 0.86 | 492 | 404 | 451 |
CHELSA EarthEnv | 0.85 | 317 | 74 | 259 |
CHPclim | 0.85 | 379 | 255 | 334 |
WorldClim 2.1 | 0.64 | 400 | -15 | 329 |
CHIRPS 2.0 | 0.88 | 276 | 101 | 227 |
CHELSA-W5E5v1.0 | 0.35 | 493 | -8 | 399 |
TerraClimate | 0.78 | 406 | -44 | 339 |
PBCOR CHELSA 1.2 | 0.75 | 372 | 110 | 303 |
PBCOR CHPclim | 0.77 | 548 | 418 | 466 |
PBCOR WorldClim 2.1 | 0.55 | 420 | -11 | 337 |
<-results_jfma %>%mutate(Correlation = round(Correlation, 2), RMSE= round(RMSE,0),Bias=round(Bias,0),MAE=round(MAE,0)) %>%
jfma_tablerownames_to_column(var = "rowname") %>%
::select(-rowname) %>%
dplyrrename("Gridded Climate Product" = "Source") %>% rename("Mean bias (mm)"="Bias")%>%
kbl(caption = "Spatial variation among 31 sites in January-to-April precipitation") %>%
kable_classic(full_width = F)
%>%save_kable("../plots/spatial_jfma_variation.png",density=900)
jfma_table jfma_table
Gridded Climate Product | Correlation | RMSE | Mean bias (mm) | MAE |
---|---|---|---|---|
CHELSA 1.2 | 0.62 | 106 | -33 | 62 |
CHELSA 2.1 | 0.60 | 104 | -4 | 69 |
CHELSA EarthEnv | 0.66 | 90 | 5 | 60 |
CHPclim | 0.86 | 90 | -45 | 56 |
WorldClim 2.1 | 0.46 | 119 | -50 | 83 |
CHIRPS 2.0 | 0.82 | 80 | -21 | 48 |
CHELSA-W5E5v1.0 | 0.14 | 123 | -8 | 82 |
TerraClimate | 0.84 | 110 | -63 | 73 |
PBCOR CHELSA 1.2 | 0.60 | 106 | -32 | 64 |
PBCOR CHPclim | 0.81 | 87 | -32 | 53 |
PBCOR WorldClim 2.1 | 0.32 | 130 | -58 | 93 |
5.4 Seasonal variation(12-month)
<- read.csv("../tables/monthly_ground.csv")
month <- read.csv("../tables/dfprecip.csv")
sites
#Filter data based on conditions
<- month %>%
acp38 filter(site %in% c("AGUACLARA", "SANMIGUEL", "BCI", "PELUCA", "BCICLEAR", "GUACHA", "CASCADAS", "PEDROMIGUEL", "GAMBOA") &
>= 1970 & Year <= 2016) %>%
Year mutate(monthlyPrecip = as.numeric(monthlyPrecip))
<- acp38 %>%
acp38_full_extent group_by(site, Month) %>%
summarise(mon_mean = mean(monthlyPrecip, na.rm = TRUE)) %>%
mutate(temporal = "1970-2016", dataset_name = "Ground")
# Calculate climatology of the ground data for every specific temporal extent
<- lapply(datasets_info, function(dataset) {
acp38_ag %>%
acp38 filter(Year >= dataset$start_year & Year <= dataset$end_year) %>%
group_by(site, Month) %>%
summarise(mon_mean = mean(monthlyPrecip, na.rm = TRUE)) %>%
mutate(temporal = dataset$temporal, dataset_name = dataset$dataset_name)
%>% bind_rows()
})
# Combine the two data frames
<- bind_rows(acp38_ag, acp38_full_extent)
acp38_ag
#calculate climatology of the ground data for every specific temporal extent
# Match lat and long
$long_dd <- sites$long_dd[match(acp38_ag$site, sites$site)]
acp38_ag$lat_dd <- sites$lat_dd[match(acp38_ag$site, sites$site)]
acp38_ag
## loop for extraction of values of raster reanalyis climatologies for specific sites and month.
for (i in 1:length(datasets_info)) {
<- list.files(datasets_info[[i]]$path, pattern = "\\.tif$", full.names = TRUE)
files_list <- terra::rast(files_list)
raster_stack $column_name]] <- NA
acp38_ag[[datasets_info[[i]]for (j in 1:12) {
$Month == j, datasets_info[[i]]$column_name] <- extract_land(raster_stack[[j]], acp38_ag[acp38_ag$Month == j, c("long_dd", "lat_dd")])
acp38_ag[acp38_ag
}
}write.csv(acp38_ag,"../tables/acp38_ag.csv")
After extracting values, we can run some statistics
<- unique(acp38_ag$site)
sites_unique <- data.frame( site = character(),
all_correlations dataset=character(),
Correlation = numeric(),
RMSE = numeric(),
stringsAsFactors = FALSE)
#loop over the dataset and each of the sites for calculating the correlation and the rmse
for (j in seq_along(datasets_info)){
print(datasets_info[[j]]$dataset_name)
for (i in seq_along(sites_unique)) {
<- datasets_info[[j]]$temporal
temporal_range <- datasets_info[[j]]$dataset_name
name <- datasets_info[[j]]$column_name
col_name <- acp38_ag[acp38_ag$site == sites_unique[i] & acp38_ag$temporal == temporal_range & acp38_ag$dataset_name==name, ]
site_data <- cor.test(site_data$mon_mean, unlist(site_data[,col_name]))$estimate
cor_test_result <-sqrt(mean(unlist(site_data[,col_name])-site_data$mon_mean)^2)
rmse<- data.frame(site = sites_unique[i], dataset = name, Correlation = cor_test_result, RMSE = rmse)
new_row <- rbind(all_correlations, new_row)
all_correlations
} }
[1] "CHELSA 1.2"
[1] "CHELSA 2.1"
[1] "CHELSA EarthEnv"
[1] "CHPclim"
[1] "WorldClim 2.1"
[1] "CHIRPS 2.0"
[1] "CHELSA-W5E5v1.0"
[1] "TerraClimate"
[1] "PBCOR CHELSA 1.2"
[1] "PBCOR CHPclim"
[1] "PBCOR WorldClim 2.1"
<- data.frame(datset=character(),
all_averagesCorrelation= numeric(),
RMSE=numeric())
<- unique(all_correlations$dataset)
datasetsfor (i in seq_along(datasets)){
=datasets[i]
dataset_name= mean(all_correlations[all_correlations$dataset==dataset_name,]$Correlation)
mean_correlation= mean(all_correlations[all_correlations$dataset==dataset_name,]$RMSE)
mean_rsme= data.frame(dataset=dataset_name,Correlation=mean_correlation,RMSE=mean_rsme)
new_row= rbind(all_averages,new_row)
all_averages
}write.csv(all_averages, file= "../tables/seasonal_variation.csv")
Plot the statistics in a table
<-all_averages%>%mutate(Correlation = round(Correlation, 2), RMSE= round(RMSE,0)) %>%
seasonality_tablerownames_to_column(var = "rowname") %>%
::select(-rowname) %>%
dplyrrename("Gridded Climate Product" = "dataset")%>%
kbl(caption = "Seasonal variation within 9 sites") %>%
kable_classic(full_width = F)
%>%save_kable("../plots/seasonal_variation.png",density=900)
seasonality_table seasonality_table
Gridded Climate Product | Correlation | RMSE |
---|---|---|
CHELSA 1.2 | 0.97 | 31 |
CHELSA 2.1 | 0.97 | 42 |
CHELSA EarthEnv | 0.94 | 24 |
CHPclim | 0.96 | 29 |
WorldClim 2.1 | 0.95 | 34 |
CHIRPS 2.0 | 0.98 | 23 |
CHELSA-W5E5v1.0 | 0.97 | 42 |
TerraClimate | 0.93 | 33 |
PBCOR CHELSA 1.2 | 0.97 | 28 |
PBCOR CHPclim | 0.96 | 36 |
PBCOR WorldClim 2.1 | 0.96 | 36 |
5.5 Interannual variability
# create a list which contains the temporal extent and location of files
<- list(
datasets_yearly list(dataset_name = "CHELSA 1.2",column_name="CHELSA1.2", temporal = "1979-2013",path = "../data_reanalysis/CHELSA 1.2/yearly"),
list(dataset_name = "CHELSA 2.1",column_name="CHELSA2.1", temporal = "1981-2010", path = "../data_reanalysis/CHELSA 2.1/yearly"),
list(dataset_name = "CHELSA EarthEnv",column_name="CHELSA_EarthEnv", temporal = "2003-2016",path = "../data_reanalysis/CHELSA EarthEnv/yearly"),
list(dataset_name = "CHIRPS 2.0",column_name="CHIRPS2.0",temporal = "1981-2016", path = "../data_reanalysis/CHIRPS 2.0/yearly"),
list(dataset_name = "CHELSA-W5E5v1.0",column_name="CHELSAW5E5v1.0", temporal = "1979-2016",path = "../data_reanalysis/CHELSA-W5E5v1.0/yearly"),
list(dataset_name = "TerraClimate",column_name="TerraClimate", temporal = "1979-2016", path = "../data_reanalysis/TerraClimate/yearly")
)
Group by year and extract for each spatial point
<- lapply(datasets_yearly, function(dataset) {
acp38_year %>% group_by(Year,site)%>%
acp38 summarise(annual_precip=sum(monthlyPrecip))%>%
mutate(long_dd=sites$long_dd[match(site, sites$site)])%>%
mutate(lat_dd=sites$lat_dd[match(site,sites$site)])%>%
mutate(temporal = dataset$temporal, dataset_name = dataset$dataset_name)
%>% bind_rows()
})
for (j in seq_along(datasets_yearly)){
print(datasets_yearly[[j]]$dataset_name)
<- list.files(datasets_yearly[[j]]$path, pattern = ".tif", full.names = TRUE)
files_list <- terra::rast(files_list)
raster_stack$column_name]] <- NA
acp38_year[[datasets_yearly[[j]]for (i in unique(acp38_year$Year)) {
if (any(grepl(i,names(raster_stack)))) {
<-grep(i, names(raster_stack))
layer_index<- raster_stack[[layer_index]]
raster_layer $Year==as.integer(i),datasets_yearly[[j]]$column_name]<- extract_land(raster_layer,acp38_year[acp38_year$Year==as.integer(i),c("long_dd","lat_dd")])
acp38_year[acp38_yearelse {
}
}
} }
Calculate the statistics for interannual variability per site and compute averages across 9 sites
<- unique(acp38_year$site)
sites_unique_year <- data.frame( site = character(),
all_correlations_year dataset=character(),
Correlation = numeric(),
RMSE = numeric(),
stringsAsFactors = FALSE)
for (j in seq_along(datasets_yearly)){
print(datasets_yearly[[j]]$dataset_name)
for (i in seq_along(sites_unique_year)) {
<- datasets_yearly[[j]]$temporal
temporal_range <- datasets_yearly[[j]]$dataset_name
name <- datasets_yearly[[j]]$column_name
col_name <- acp38_year[acp38_year$site == sites_unique_year[i] & acp38_year$temporal == temporal_range & acp38_year$dataset_name==name,]
site_data <- cor.test(as.numeric(site_data$annual_precip), as.numeric(unlist(site_data[, col_name])), na.rm = TRUE)$estimate
cor_test_result <- sqrt(mean((as.numeric(unlist(site_data[, col_name])) - site_data$annual_precip)^2, na.rm = TRUE))
rmse <- data.frame(site = sites_unique_year[i], dataset = name, Correlation = cor_test_result, RMSE = rmse)
new_row <- rbind(all_correlations_year, new_row)
all_correlations_year
}
}
<- all_correlations_year %>%
summary_table group_by(dataset) %>%
summarise(Correlation = mean(Correlation, na.rm = TRUE),
RMSE = mean(RMSE, na.rm = TRUE))
<- summary_table %>%
interannual_table mutate(Correlation = round(Correlation, 2), RMSE = round(RMSE, 0)) %>%
rename("Mean Correlation" = Correlation, "Mean RMSE" = RMSE) %>%
rownames_to_column(var = "Dataset") %>%
kbl(caption = "Summary of Correlation and RMSE by Dataset")%>% kable_classic(full_width = FALSE)
%>%save_kable("../plots/interannual_table.png",density=900)
interannual_tablewrite.csv(summary_table, file= "../tables/interannual_variation.csv")
write.csv(acp38_year, file = "../tables/acp38_year.csv")
interannual_table