changed T and F to TRUE and FALSE

master
jan 1 year ago
parent 0e1d9e3cad
commit 6ebfc7f50a

@ -1,4 +1,4 @@
exclusions: list.files(path = 'inst/doc', full.names = T)
exclusions: list.files(path = 'inst/doc', full.names = TRUE)
linters: with_defaults(
# we use snake case
camel_case_linter = NULL,

@ -94,7 +94,7 @@ get_stats_ = function (endpoint, cache) {
#' @param cache Optional path to a directory were responses will be cached. If not NA, no requests will be made when a request for the given is already cached.
#' @return Result of a Request to openSenseMap API
#' @noRd
osem_get_resource = function (host, path, ..., type = 'parsed', progress = T, cache = NA) {
osem_get_resource = function (host, path, ..., type = 'parsed', progress = TRUE, cache = NA) {
query = list(...)
if (!is.na(cache)) {
filename = osem_cache_filename(path, query, host) %>% paste(cache, ., sep = '/')

@ -64,7 +64,7 @@ osem_measurements_archive.default = function (x, ...) {
#' sensorFilter = sensors
#' )
#' }
osem_measurements_archive.sensebox = function (x, fromDate, toDate = fromDate, sensorFilter = ~ T, ..., progress = T) {
osem_measurements_archive.sensebox = function (x, fromDate, toDate = fromDate, sensorFilter = ~ TRUE, ..., progress = TRUE) {
if (nrow(x) != 1)
stop('this function only works for exactly one senseBox!')

@ -159,7 +159,7 @@ parse_senseboxdata = function (boxdata) {
boxdata[c(
'loc', 'locations', 'currentLocation', 'sensors', 'image', 'boxType', 'lastMeasurementAt', 'grouptag'
)] = NULL
thebox = as.data.frame(boxdata, stringsAsFactors = F)
thebox = as.data.frame(boxdata, stringsAsFactors = FALSE)
# parse timestamps (updatedAt might be not defined)
thebox$createdAt = isostring_as_date(thebox$createdAt)
@ -176,7 +176,7 @@ parse_senseboxdata = function (boxdata) {
# create a dataframe of sensors
thebox$sensors = sensors %>%
recursive_lapply(function (x) if (is.null(x)) NA else x) %>% # replace NULLs with NA
lapply(as.data.frame, stringsAsFactors = F) %>%
lapply(as.data.frame, stringsAsFactors = FALSE) %>%
dplyr::bind_rows(.) %>%
dplyr::select(phenomenon = title, id = X_id, unit, sensor = sensorType) %>%
list

@ -22,8 +22,8 @@ plot.sensebox = function (x, ..., mar = c(2, 2, 1, 1)) {
oldpar = par()
par(mar = mar)
plot(world, col = 'gray', xlim = bbox[c(1, 3)], ylim = bbox[c(2, 4)], axes = T, ...)
plot(geom, add = T, col = x$exposure, ...)
plot(world, col = 'gray', xlim = bbox[c(1, 3)], ylim = bbox[c(2, 4)], axes = TRUE, ...)
plot(geom, add = TRUE, col = x$exposure, ...)
legend('left', legend = levels(x$exposure), col = 1:length(x$exposure), pch = 1)
par(mar = oldpar$mar)
@ -39,7 +39,7 @@ print.sensebox = function(x, columns = c('name', 'exposure', 'lastMeasurement',
#' @export
summary.sensebox = function(object, ...) {
cat('boxes total:', nrow(object), fill = T)
cat('boxes total:', nrow(object), fill = TRUE)
cat('\nboxes by exposure:')
table(object$exposure) %>% print()
cat('\nboxes by model:')
@ -59,10 +59,10 @@ summary.sensebox = function(object, ...) {
oldest = object[object$createdAt == min(object$createdAt), ]
newest = object[object$createdAt == max(object$createdAt), ]
cat('oldest box:', format(oldest$createdAt, '%F %T'), paste0('(', oldest$name, ')'), fill = T)
cat('newest box:', format(newest$createdAt, '%F %T'), paste0('(', newest$name, ')'), fill = T)
cat('oldest box:', format(oldest$createdAt, '%F %T'), paste0('(', oldest$name, ')'), fill = TRUE)
cat('newest box:', format(newest$createdAt, '%F %T'), paste0('(', newest$name, ')'), fill = TRUE)
cat('\nsensors per box:', fill = T)
cat('\nsensors per box:', fill = TRUE)
lapply(object$phenomena, length) %>%
as.numeric() %>%
summary() %>%

@ -11,9 +11,9 @@ osem_measurements_archive(x, ...)
x,
fromDate,
toDate = fromDate,
sensorFilter = ~T,
sensorFilter = ~TRUE,
...,
progress = T
progress = TRUE
)
}
\arguments{

@ -46,6 +46,15 @@ test_that('osem_measurements_archive works for one box', {
expect_s3_class(m, c('data.frame'))
})
test_that('osem_measurements_archive sensorFilter works for one box', {
check_api()
if (is.null(box)) skip('no box data could be fetched')
m = osem_measurements_archive(box, as.POSIXlt('2018-08-08'), sensorFilter = ~ phenomenon == 'Temperatur')
expect_length(m, 2) # one column for Temperatur + createdAt
expect_s3_class(m, c('data.frame'))
})
test_that('osem_measurements_archive fails for multiple boxes', {
check_api()
if (is.null(boxes)) skip('no box data available')

@ -66,7 +66,7 @@ summary(boxes) -> summary.data.frame
Another feature of interest is the spatial distribution of the boxes: `plot()`
can help us out here. This function requires a bunch of optional dependencies though.
```{r, message=F, warning=F}
```{r, message=FALSE, warning=FALSE}
if (!require('maps')) install.packages('maps')
if (!require('maptools')) install.packages('maptools')
if (!require('rgeos')) install.packages('rgeos')

@ -28,7 +28,7 @@ Its main goals are to provide means for:
Before we look at actual observations, lets get a grasp of the openSenseMap
datasets' structure.
```{r results = F}
```{r results = FALSE}
library(magrittr)
library(opensensmapr)
@ -48,7 +48,7 @@ couple of minutes ago.
Another feature of interest is the spatial distribution of the boxes: `plot()`
can help us out here. This function requires a bunch of optional dependencies though.
```{r, message=F, warning=F}
```{r, message=FALSE, warning=FALSE}
if (!require('maps')) install.packages('maps')
if (!require('maptools')) install.packages('maptools')
if (!require('rgeos')) install.packages('rgeos')
@ -82,7 +82,7 @@ We should check how many sensor stations provide useful data: We want only those
boxes with a PM2.5 sensor, that are placed outdoors and are currently submitting
measurements:
```{r results = F, eval=FALSE}
```{r results = FALSE, eval=FALSE}
pm25_sensors = osem_boxes(
exposure = 'outdoor',
date = Sys.time(), # ±4 hours
@ -104,7 +104,7 @@ We could call `osem_measurements(pm25_sensors)` now, however we are focusing on
a restricted area of interest, the city of Berlin.
Luckily we can get the measurements filtered by a bounding box:
```{r, results=F, message=F}
```{r, results=FALSE, message=FALSE}
library(sf)
library(units)
library(lubridate)
@ -113,7 +113,7 @@ library(dplyr)
```
Since the API takes quite long to response measurements, especially filtered on space and time, we do not run the following chunks for publication of the package on CRAN.
```{r bbox, results = F, eval=FALSE}
```{r bbox, results = FALSE, eval=FALSE}
# construct a bounding box: 12 kilometers around Berlin
berlin = st_point(c(13.4034, 52.5120)) %>%
st_sfc(crs = 4326) %>%
@ -138,9 +138,9 @@ plot(pm25)
Now we can get started with actual spatiotemporal data analysis.
First, lets mask the seemingly uncalibrated sensors:
```{r, warning=F}
```{r, warning=FALSE}
outliers = filter(pm25, value > 100)$sensorId
bad_sensors = outliers[, drop = T] %>% levels()
bad_sensors = outliers[, drop = TRUE] %>% levels()
pm25 = mutate(pm25, invalid = sensorId %in% bad_sensors)
```
@ -148,7 +148,7 @@ pm25 = mutate(pm25, invalid = sensorId %in% bad_sensors)
Then plot the measuring locations, flagging the outliers:
```{r}
st_as_sf(pm25) %>% st_geometry() %>% plot(col = factor(pm25$invalid), axes = T)
st_as_sf(pm25) %>% st_geometry() %>% plot(col = factor(pm25$invalid), axes = TRUE)
```
Removing these sensors yields a nicer time series plot:

Loading…
Cancel
Save