mirror of
https://github.com/sensebox/opensensmapr
synced 2025-07-04 06:00:22 +02:00
return phenomena as named list
This commit is contained in:
parent
0f80075bf5
commit
53b77977e0
1 changed files with 4 additions and 5 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue