From 07ab9b30961cac1fe4c01159e784aacfd0f91a5c Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Sat, 13 Jan 2018 16:17:59 +0100 Subject: [PATCH] fix summary.sensebox() last_measurement_within --- R/box_utils.R | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/R/box_utils.R b/R/box_utils.R index c8be288..d5d964f 100644 --- a/R/box_utils.R +++ b/R/box_utils.R @@ -48,14 +48,13 @@ summary.sensebox = function(object, ...) { cat('\n') diffNow = (utc_date(Sys.time()) - object$lastMeasurement) %>% as.numeric(unit='hours') - neverActive = object[is.na(object$lastMeasurement), ] %>% nrow() list( 'last_measurement_within' = c( - '1h' = nrow(object[diffNow <= 1, ]) - neverActive, - '1d' = nrow(object[diffNow <= 24, ]) - neverActive, - '30d' = nrow(object[diffNow <= 720, ]) - neverActive, - '365d' = nrow(object[diffNow <= 8760, ]) - neverActive, - 'never' = neverActive + '1h' = nrow(dplyr::filter(object, diffNow <= 1)), + '1d' = nrow(dplyr::filter(object, diffNow <= 24)), + '30d' = nrow(dplyr::filter(object, diffNow <= 720)), + '365d' = nrow(dplyr::filter(object, diffNow <= 8760)), + 'never' = nrow(dplyr::filter(object, is.na(lastMeasurement))) ) ) %>% print()