R/list_extract_assign.R

extract_lst <- function(x, i) {
  x[which(names(x) %in% i)]
}

assign_lst <- function(x, value, pos = names(value)) {
  stopifnot(length(value) == length(pos))
  for (i in seq_along(pos)) {
    x[which(names(x) %in% pos[i])] <- value[[i]]
  }
  x
}
twolodzko/lolplyr documentation built on May 14, 2019, 8:22 a.m.