R/extract.R

extract <- function(x, what){
  if(what %in% names(x)){
    result <- x[[what]]
  }else{
    result <- list()
    for(i in 1:length(x)){
      result[[i]] <- x[[i]][[what]]
    }
    if(all(unlist(lapply(result, length)) == 1)){
      result <- unlist(result)
    }
  }
  return(result)
}

Try the DoTC package in your browser

Any scripts or data that you put into this service are public.

DoTC documentation built on May 2, 2019, 3:36 p.m.