R/cbind_TargetDatas.R

Defines functions cbind_TargetDatas

Documented in cbind_TargetDatas

#' bind multiple stN class object
#' @importFrom magrittr %>%
#' @importFrom dplyr group_by summarize left_join
#' @importFrom purrr reduce
#' @export
#' @examples
#' x <- list(yield_tmin, yield_watertem)
#' cbind_TargetDatas(x, target = "yield", join_by = "Year")

cbind_TargetDatas <- function(target = NULL, join_by = NULL, ...){
  x <- list(...) # THIS WILL BE A LIST STORING EVERYTHING:
  x <- x %>%
    reduce(rbind) %>%
    group_by(county) %>%
    summarize(data = list(reduce(data, left_join, by = c(join_by, target)))); x
  return(x)
}
WeiquanLuo/stNet documentation built on Nov. 24, 2019, 5:11 p.m.