R/helpers.R

#' @import rlang

get_list_item <- function(l, index, get_name = FALSE, default = "") {
  if (length(index) == 1) {
    if (get_name) {
      return(names(l[index[[1]]]) %||% default)
    } else {
      return(l[[index[[1]]]])
    }
  } else {
    return(get_list_item(l[[index[[1]]]], index[-1], get_name, default))
  }
}
domjarkey/crunchscripts documentation built on June 6, 2019, 7:43 p.m.