make R CMD check --as-cran pass

fixes #9

also update examples & shorten their runtime a bit
pull/17/head
Norwin 6 年之前
父節點 44d9026936
當前提交 a8a1effa48
簽署人: norwin
GPG Key ID: 24BC059DE24C43A3

@ -1,3 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^tools/.*$
^CHANGES\.md$
^tools*$

2
.gitignore vendored

@ -3,5 +3,7 @@
.Rhistory
.RData
.Ruserdata
..Rcheck
*.log
opensensmapr_*.tar.gz

@ -15,13 +15,19 @@ Suggests:
rgeos,
sf,
knitr,
rmarkdown
rmarkdown,
lubridate,
units
Author: Norwin Roosen
Maintainer: Norwin Roosen <maintenance@nroo.de>
Description: This package ingests data (measurements, sensorstations) from the
API of opensensemap.org for analysis in R.
The package aims to be compatible with sf and the tidyverse.
License: GPL-2
Maintainer: Norwin Roosen <bugs@nroo.de>
Description: Download data (environmental measurements, sensorstations) from the
API of open data sensor web platform 'opensensemap.org' for analysis in R.
This platform provides realtime data of more than 1000 low-cost sensor
stations for PM10, PM2.5, temperature, humidity, UV-A intensity and more
phenomena.
The package aims to be compatible with sf and the tidyverse, and provides
several helper functions for data exploration and transformation.
License: GPL (>= 2) | file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1

@ -24,5 +24,7 @@ export(osem_measurements)
export(osem_phenomena)
export(st_as_sf.osem_measurements)
export(st_as_sf.sensebox)
importFrom(graphics,legend)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(magrittr,"%>%")

@ -85,7 +85,7 @@ osem_boxes = function (exposure = NA, model = NA, grouptag = NA,
#' @export
#' @examples
#' # get a specific box by ID
#' b = osem_box('593bcd656ccf3b0011791f5a')
#' b = osem_box('57000b8745fd40c8196ad04c')
#'
osem_box = function (boxId, endpoint = 'https://api.opensensemap.org') {
get_box_(boxId, endpoint = endpoint)

@ -75,7 +75,7 @@ summary.sensebox = function(object, ...) {
# ==============================================================================
#
#' Converts a foreign object to an sensebox data.frame.
#' Converts a foreign object to a sensebox data.frame.
#' @param x A data.frame to attach the class to
#' @export
osem_as_sensebox = function(x) {
@ -120,6 +120,6 @@ mutate.sensebox = dplyr_class_wrapper(osem_as_sensebox)
#' @return The object with an st_geometry column attached.
#' @export
st_as_sf.sensebox = function (x, ...) {
sf:::st_as_sf.data.frame(x, ..., coords = c('lon', 'lat'), crs = 4326)
NextMethod(x, ..., coords = c('lon', 'lat'), crs = 4326)
}

@ -36,9 +36,7 @@ osem_measurements = function (x, ...) UseMethod('osem_measurements')
#' @export
#' @examples
#' # get measurements from all boxes
#' \dontrun{
#' osem_measurements('PM2.5')
#' }
#' osem_measurements('Windrichtung')
#'
osem_measurements.default = function (x, ...) {
bbox = structure(c(-180, -90, 180, 90), class = 'bbox')
@ -54,7 +52,7 @@ osem_measurements.default = function (x, ...) {
#' bbox = structure(c(7, 51, 8, 52), class = 'bbox')
#' osem_measurements(bbox, 'Temperatur')
#'
#' points = sf::st_multipoint(matrix(c(7, 8, 51, 52), 2, 2))
#' points = sf::st_multipoint(matrix(c(7.5, 7.8, 51.7, 52), 2, 2))
#' bbox2 = sf::st_bbox(points)
#' osem_measurements(bbox2, 'Temperatur', exposure = 'outdoor')
#'
@ -80,7 +78,7 @@ osem_measurements.bbox = function (x, phenomenon, exposure = NA,
#' osem_measurements(b, phenomenon = 'Temperatur')
#'
#' # ...or a single box
#' b = osem_box('593bcd656ccf3b0011791f5a')
#' b = osem_box('57000b8745fd40c8196ad04c')
#' osem_measurements(b, phenomenon = 'Temperatur')
#'
osem_measurements.sensebox = function (x, phenomenon, exposure = NA,

@ -56,6 +56,5 @@ mutate.osem_measurements = dplyr_class_wrapper(osem_as_measurements)
#' @return The object with an st_geometry column attached.
#' @export
st_as_sf.osem_measurements = function (x, ...) {
sf:::st_as_sf.data.frame(x, ..., coords = c('lon', 'lat'), crs = 4326)
NextMethod(x, ..., coords = c('lon', 'lat'), crs = 4326)
}

@ -7,8 +7,8 @@
#' \item general statistics about the openSenseMap database.
#' }
#' Additionally, helper functions are provided to ease the integration with the
#' \code{\link{sf}} package for spatial analysis as well as \code{\link{dplyr}}
#' for general data handling.
#' \code{\link[sf]{sf}} package for spatial analysis as well as
#' \code{\link[dplyr]{dplyr}} for general data handling.
#'
#' @section Retrieving senseBox metadata:
#' On the openSenseMap, measurements are provided by sensors which are assigned
@ -44,7 +44,7 @@
#' \item a list of senseBoxes, previously retrieved through
#' \code{\link{osem_box}} or \code{\link{osem_boxes}}.
#' \item a geographic bounding box, which can be generated with the
#' \code{\link{sf}} package.
#' \code{\link[sf]{sf}} package.
#' \item a time frame
#' \item a exposure type of the given box
#' }
@ -63,7 +63,7 @@
#' Transform a foreign object to a sensebox data.frame or osem_measurements
#' by attaching the required classes and attributes.
#' \item \code{\link{st_as_sf.sensebox}} & \code{\link{st_as_sf.osem_measurements}}:
#' Transform the senseBoxes or measurements into an \code{\link{sf}}
#' Transform the senseBoxes or measurements into an \code{\link[sf]{sf}}
#' compatible format for spatial analysis.
#' \item \code{filter.sensebox()} & \code{mutate.sensebox()}: for use with
#' \code{\link{dplyr}}.
@ -76,7 +76,7 @@
#' @name opensensmapr
'_PACKAGE'
#' @importFrom graphics plot
#' @importFrom graphics plot legend par
#' @importFrom magrittr %>%
`%>%` = magrittr::`%>%`

@ -23,9 +23,9 @@ osem_phenomena = function (boxes) UseMethod('osem_phenomena')
#' osem_boxes(grouptag = 'ifgi', exposure = 'outdoor', date = Sys.time())
#' )
#'
#' # get phenomena with at least 10 sensors on opensensemap
#' # get phenomena with at least 30 sensors on opensensemap
#' phenoms = osem_phenomena(osem_boxes())
#' names(phenoms[phenoms > 9])
#' names(phenoms[phenoms > 29])
#'
osem_phenomena.sensebox = function (boxes) {
p = Reduce(`c`, boxes$phenomena) %>% # get all the row contents in a single vector

@ -14,8 +14,8 @@ The opensensmapr package provides functions for
\item general statistics about the openSenseMap database.
}
Additionally, helper functions are provided to ease the integration with the
\code{\link{sf}} package for spatial analysis as well as \code{\link{dplyr}}
for general data handling.
\code{\link[sf]{sf}} package for spatial analysis as well as
\code{\link[dplyr]{dplyr}} for general data handling.
}
\section{Retrieving senseBox metadata}{
@ -54,7 +54,7 @@ given phenomenon only. A subset of measurements may be selected by
\item a list of senseBoxes, previously retrieved through
\code{\link{osem_box}} or \code{\link{osem_boxes}}.
\item a geographic bounding box, which can be generated with the
\code{\link{sf}} package.
\code{\link[sf]{sf}} package.
\item a time frame
\item a exposure type of the given box
}
@ -73,8 +73,11 @@ The package aims to be compatible with the tidyverse.
Helpers are implemented to ease the further usage of the retrieved data:
\itemize{
\item \code{\link{osem_as_sensebox}} & \code{\link{osem_as_measurements}}:
Transform a foreign object to a sensebox data.frame or osem_measurements
by attaching the required classes and attributes.
\item \code{\link{st_as_sf.sensebox}} & \code{\link{st_as_sf.osem_measurements}}:
Transform the senseBoxes or measurements into an \code{\link{sf}}
Transform the senseBoxes or measurements into an \code{\link[sf]{sf}}
compatible format for spatial analysis.
\item \code{filter.sensebox()} & \code{mutate.sensebox()}: for use with
\code{\link{dplyr}}.

@ -2,7 +2,7 @@
% Please edit documentation in R/box_utils.R
\name{osem_as_sensebox}
\alias{osem_as_sensebox}
\title{Converts a foreign object to an sensebox data.frame.}
\title{Converts a foreign object to a sensebox data.frame.}
\usage{
osem_as_sensebox(x)
}
@ -10,5 +10,5 @@ osem_as_sensebox(x)
\item{x}{A data.frame to attach the class to}
}
\description{
Converts a foreign object to an sensebox data.frame.
Converts a foreign object to a sensebox data.frame.
}

@ -19,7 +19,7 @@ Get a single senseBox by its ID
}
\examples{
# get a specific box by ID
b = osem_box('593bcd656ccf3b0011791f5a')
b = osem_box('57000b8745fd40c8196ad04c')
}
\seealso{

@ -64,15 +64,13 @@ a bounding box spanning the whole world.
\examples{
# get measurements from all boxes
\dontrun{
osem_measurements('PM2.5')
}
osem_measurements('Windrichtung')
# get measurements from sensors within a bounding box
bbox = structure(c(7, 51, 8, 52), class = 'bbox')
osem_measurements(bbox, 'Temperatur')
points = sf::st_multipoint(matrix(c(7, 8, 51, 52), 2, 2))
points = sf::st_multipoint(matrix(c(7.5, 7.8, 51.7, 52), 2, 2))
bbox2 = sf::st_bbox(points)
osem_measurements(bbox2, 'Temperatur', exposure = 'outdoor')
@ -81,7 +79,7 @@ b = osem_boxes(grouptag = 'ifgi')
osem_measurements(b, phenomenon = 'Temperatur')
# ...or a single box
b = osem_box('593bcd656ccf3b0011791f5a')
b = osem_box('57000b8745fd40c8196ad04c')
osem_measurements(b, phenomenon = 'Temperatur')
}

@ -34,9 +34,9 @@ osem_phenomena(
osem_boxes(grouptag = 'ifgi', exposure = 'outdoor', date = Sys.time())
)
# get phenomena with at least 10 sensors on opensensemap
# get phenomena with at least 30 sensors on opensensemap
phenoms = osem_phenomena(osem_boxes())
names(phenoms[phenoms > 9])
names(phenoms[phenoms > 29])
}
\seealso{

Loading…
取消
儲存