mirror of
https://github.com/sensebox/opensensmapr
synced 2025-02-22 14:53:57 +01:00
fix issue with missing lastMeasurement
This commit is contained in:
parent
ddc6289ce3
commit
ee491673fa
2 changed files with 10 additions and 0 deletions
|
@ -24,3 +24,12 @@ is_non_interactive = function () {
|
||||||
ff = sapply(sys.calls(), function(f) as.character(f[1]))
|
ff = sapply(sys.calls(), function(f) as.character(f[1]))
|
||||||
any(ff %in% c('knit2html', 'render')) || !interactive()
|
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)
|
||||||
|
}
|
||||||
|
|
1
R/box.R
1
R/box.R
|
@ -157,6 +157,7 @@ parse_senseboxdata = function (boxdata) {
|
||||||
|
|
||||||
# create a dataframe of sensors
|
# create a dataframe of sensors
|
||||||
thebox$sensors = 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) %>%
|
lapply(as.data.frame, stringsAsFactors = F) %>%
|
||||||
dplyr::bind_rows(.) %>%
|
dplyr::bind_rows(.) %>%
|
||||||
dplyr::select(phenomenon = title, id = X_id, unit, sensor = sensorType) %>%
|
dplyr::select(phenomenon = title, id = X_id, unit, sensor = sensorType) %>%
|
||||||
|
|
Loading…
Add table
Reference in a new issue