R/evoplot.R

#' Plot temporal evolution of variable by PFT
#' 
#' @param f path to a LPJ-GUESS output file
#' @import readr
#' @import ggplot2
#' @import dplyr
#' @import tidyr
#' @export
evoplot <- function(f) {
  dat <- read_table(f)
  datt <- dat %>% gather(PFT, Value, BNE:C4G)
  datt %>% group_by(Year, PFT) %>% 
    summarise(mean_value = mean(Value)) %>% 
    group_by(PFT) %>% 
    filter(sum(mean_value) != 0) -> datt
  
  ggplot(datt, aes(x = Year, y = mean_value)) +
    geom_area(aes(fill = PFT))
}
cszang/guessex documentation built on May 14, 2019, 12:26 p.m.