diff --git a/R/plot-compare.R b/R/plot-compare.R index 2320f7c..152751b 100644 --- a/R/plot-compare.R +++ b/R/plot-compare.R @@ -46,9 +46,9 @@ plot_compare <- function(fits, labels = NULL, year = NULL, gm1 <- geo_mean(df1$Mean) gm2 <- geo_mean(df2$Mean) fout$Mean <- fout$Mean / gm2 * gm1 - fout$Qlower <- fout$Qlower / gm2 * gm1 - fout$Qupper <- fout$Qupper / gm2 * gm1 - fout$Median <- fout$Median / gm2 * gm1 + fout$Qlower <- fout$Qlower / gm2 * gm1 + fout$Qupper <- fout$Qupper / gm2 * gm1 + fout$Median <- fout$Median / gm2 * gm1 df0[[i]] <- fout } } diff --git a/R/rescale-index.R b/R/rescale-index.R index edd9705..41b6b53 100644 --- a/R/rescale-index.R +++ b/R/rescale-index.R @@ -7,8 +7,22 @@ #' @import dplyr #' @export #' -rescale_index <- function(idx1, idx2) { +rescale_index <- function(fit1, fit2, rescale_series = 1) { + + for (i in 1:length(fits)) { + if (i != rescale_series) { + fout <- df0[[i]] + df1 <- df0[[rescale_series]] %>% filter(Year %in% fout$Year) + df2 <- df0[[i]] %>% filter(Year %in% df1$Year) + gm1 <- geo_mean(df1$Mean) + gm2 <- geo_mean(df2$Mean) + fout$Mean <- fout$Mean / gm2 * gm1 + fout$Qlower <- fout$Qlower / gm2 * gm1 + fout$Qupper <- fout$Qupper / gm2 * gm1 + fout$Median <- fout$Median / gm2 * gm1 + df0[[i]] <- fout + } + } - return(coefs) }