R/list_lengths.R

Defines functions valid_input list_lengths

Documented in list_lengths

#' @title List Lengths
#' @description Returns a vector of the lengths of each element in the vector.
#' @param x a vector of lists
#' @return vector
#' @export

list_lengths <- function(x){
  valid_input(x)
  lengths <- lapply(x, length)
  unlist(lengths)
}

#Helper function to ensure inputs are specified
valid_input <- function(input){
  if(is.null(input)){
    stop("\n'x' must not be null")
  }
  TRUE
}
matthiasronnau/matthias documentation built on June 15, 2022, 11:44 p.m.