@ -24,3 +24,12 @@ is_non_interactive = function () {
ff = sapply(sys.calls(), function(f) as.character(f[1]))
any(ff %in% c('knit2html', 'render')) || !interactive()
}
#' custom recursive lapply with better handling of NULL values
#' from https://stackoverflow.com/a/38950304
recursive_lapply = function(x, fn) {
if (is.list(x))
lapply(x, recursive_lapply, fn)
else
fn(x)
@ -157,6 +157,7 @@ parse_senseboxdata = function (boxdata) {
# create a dataframe of sensors
thebox$sensors = sensors %>%
recursive_lapply(function (x) if (is.null(x)) NA else x) %>% # replace NULLs with NA
lapply(as.data.frame, stringsAsFactors = F) %>%
dplyr::bind_rows(.) %>%
dplyr::select(phenomenon = title, id = X_id, unit, sensor = sensorType) %>%