df = readRDS("data-raw/Table2_trend.rds") %>%
dplyr::rename(type_area = count)
lev_old = c("D", "I", "S", "avgs", "maxs", "sums")
lev_new = c('HWD', 'HWI', 'HWS', 'HWA_mean', 'HWA_max', 'HWA_sum')
df$variable %<>% mapvalues(lev_old, lev_new)
tidy_table <- function(df, value.var = "slope") {
d_slope = df %>% dcast(name + type_area ~ variable, value.var = value.var) %>%
.[order(type_area), ]
d_head = d_slope$name %>% strsplit("_") %>% do.call(rbind, .) %>% as.data.table() %>%
set_colnames(c("type_HI", "variable", "method"))
cbind(d_head, d_slope[, -1])
}
d_slope <- tidy_table(df, "slope") %>% dt_round(3)
d_pvalue <- tidy_table(df, "pvalue") %>% dt_round(3)
write_list2xlsx(list(slope = d_slope, pvalue = d_pvalue), "Table2_trends")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.