1
0
Fork 0
mirror of https://github.com/sensebox/opensensmapr synced 2025-06-07 08:36:08 +02:00
opensensmapR/R/phenomena.R
noerw 4f95ae19a8 hello CRAN :^|
i'm all in for quality control, but some of these checks are just ridiculous..
rejecting a package b/c of typos auto-checked against an aspell dict - in a text
read by ~1% of users?? and the only workaround (whitelisting words) is not
documented, and TOTALLY overengineered?!?
going for the tech elitism awards, huh
/rant

but hey, we're on board of that train now! :}
2018-05-14 00:56:10 +02:00

37 lines
1.3 KiB
R

# ==============================================================================
#
#' Get the counts of sensors for each observed phenomenon.
#'
#' @param boxes A \code{sensebox data.frame} of boxes
#' @return A named \code{list} containing the count of sensors observing a
#' phenomenon per phenomenon
#' @export
osem_phenomena = function (boxes) UseMethod('osem_phenomena')
# ==============================================================================
#
#' @describeIn osem_phenomena Get counts of sensors observing each phenomenon
#' from a set of senseBoxes.
#' @export
#' @seealso \code{\link{osem_boxes}}
#' @examples
#' # get the phenomena for a single senseBox
#' osem_phenomena(osem_box('593bcd656ccf3b0011791f5a'))
#'
#' # get the phenomena for a group of senseBoxes
#' osem_phenomena(
#' osem_boxes(grouptag = 'ifgi', exposure = 'outdoor', date = Sys.time())
#' )
#'
#' # get phenomena with at least 30 sensors on opensensemap
#' \donttest{
#' phenoms = osem_phenomena(osem_boxes())
#' names(phenoms[phenoms > 29])
#' }
osem_phenomena.sensebox = function (boxes) {
p = Reduce(`c`, boxes$phenomena) %>% # get all the row contents in a single vector
table() %>% # get count for each phenomenon
as.list()
p[order(unlist(p), decreasing = T)]
}