From 53b77977e0a68959608813012a46114038a932be Mon Sep 17 00:00:00 2001 From: noerw Date: Sun, 13 Aug 2017 16:03:46 +0200 Subject: [PATCH] return phenomena as named list --- R/phenomena.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/R/phenomena.R b/R/phenomena.R index 182710c..e06c00a 100644 --- a/R/phenomena.R +++ b/R/phenomena.R @@ -3,8 +3,8 @@ #' Get the counts of sensors for each observed phenomenon. #' #' @param boxes A \code{sensebox data.frame} of boxes -#' @return An \code{data.frame} containing the count of sensors observing a -#' phenomenon per column. +#' @return A named \code{list} containing the count of sensors observing a +#' phenomenon per phenomenon #' @export osem_phenomena = function (boxes) UseMethod('osem_phenomena') @@ -25,11 +25,10 @@ osem_phenomena = function (boxes) UseMethod('osem_phenomena') #' #' # get phenomena with at least 10 sensors on opensensemap #' phenoms = osem_phenomena(osem_boxes()) -#' colnames(dplyr::select_if(phenoms, function(v) v > 9)) +#' names(phenoms[phenoms > 9]) #' osem_phenomena.sensebox = function (boxes) { Reduce(`c`, boxes$phenomena) %>% # get all the row contents in a single vector table() %>% # get count for each phenomenon - t() %>% # transform the table to a df - as.data.frame.matrix() + as.list() }