R/retrieve_layer_by_type.R

Defines functions retrieve_layer_by_type

retrieve_layer_by_type <- function(twig_obj, type) {

  outcome <- lapply(twig_obj$layers, function(x) if (x$type == type) x else NULL)

  lyr <- Filter(Negate(is.null), outcome)
  if (length(lyr) == 1 & type != "event") {
    lyr <- lyr[[1]] 
  }
  lyr
}

Try the twig package in your browser

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

twig documentation built on April 12, 2025, 2:08 a.m.