R/utils.R

Defines functions rm_null_obs is_null_obs

# https://stackoverflow.com/questions/26539441/remove-null-elements-from-list-of-lists
# remove NULL nodes from a list
# helper function for rm_null_obs
is_null_obs <- function(x) {
  is.null(x) | all(sapply(x, is.null))
}

rm_null_obs <- function(x) {
  x <- Filter(Negate(is_null_obs), x)
  lapply(x, function(x) if (is.list(x)) rm_null_obs(x) else x)
}
ozean12/sentryR documentation built on July 18, 2024, 12:47 p.m.