Commit 8d841000 by Jan Wijffels

add citizenair_compare

parent b7fbe585
......@@ -24,4 +24,4 @@ Imports:
httr,
lubridate,
rgeos
Suggests: BelgiumMaps.StatBel
Suggests: BelgiumMaps.StatBel, ggplot2
......@@ -2,7 +2,9 @@
S3method(as.data.frame,citizenair_userdata)
S3method(error_message,default)
S3method(plot,citizenair_comparison_ircel)
export(CitizenAir)
export(citizenair_compare)
export(error_message)
export(read_citizenair)
export(read_stations)
......@@ -22,6 +24,7 @@ importFrom(fasttime,fastPOSIXct)
importFrom(httr,GET)
importFrom(httr,content)
importFrom(lubridate,as.interval)
importFrom(lubridate,parse_date_time)
importFrom(readxl,excel_sheets)
importFrom(readxl,read_excel)
importFrom(rgeos,gIntersects)
......@@ -41,6 +44,9 @@ importFrom(sensorweb4R,time)
importFrom(sensorweb4R,timeseries)
importFrom(sp,CRS)
importFrom(sp,SpatialPointsDataFrame)
importFrom(stats,lm)
importFrom(stats,na.pass)
importFrom(stats,predict)
importFrom(tools,file_path_sans_ext)
importFrom(utils,capture.output)
importFrom(utils,head)
......
......@@ -6,12 +6,13 @@
#' @importFrom fasttime fastPOSIXct
#' @importFrom rmarkdown run
#' @importFrom sensorweb4R resourceURL id label as.Endpoint fetch timeseries phenomenon as.Timeseries getData time lastValue firstValue Station
#' @importFrom lubridate as.interval
#' @importFrom lubridate as.interval parse_date_time
#' @importFrom httr GET content
#' @importFrom sp CRS SpatialPointsDataFrame
#' @importFrom rgeos gIntersects
#' @import methods
#' @import R6
#' @importFrom stats lm na.pass predict
NULL
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/comparisons.R
\name{citizenair_compare}
\alias{citizenair_compare}
\title{Compare citizen data to official data}
\usage{
citizenair_compare(x, reference = "official", sensor = "citizen")
}
\arguments{
\item{x}{a data.frame with columns time/group/value}
\item{reference}{a character string of length 1 indicating in the \code{group} column of \code{x} what is the reference value.
Defaults to 'official'}
\item{sensor}{a character string of length 1 indicating in the \code{group} column of \code{x} what is the comparison value.
Defaults to 'citizen'}
}
\value{
an object of class \code{citizenair_comparison_ircel} which is a list with elements
\enumerate{
\item{data: the data containing columns time, REF, SENSOR, OLSQ, lower_CI, upper_CI, lower_PI, upper_PI and e}
\item{model: an object of class lm represendint the model SENSOR ~ REF}
\item{overview: a data.frame with columns statistic, time, REF, SENSOR, OLSQ, lower_CI, upper_CI, lower_PI, upper_PI and e with the
minimum/Q25/median/mean/Q75/max for each of these columns as well as the number of valid data points and the number of NA values}
}
}
\description{
Compare citizen data to official data
}
\examples{
x <- data.frame(
time = rep(seq.Date(from = Sys.Date()-364, to = Sys.Date(), by = "day"), 2),
group = sample(c("official", "citizen"), size = 365*2, replace = TRUE),
value = rnorm(365*2))
comparison <- citizenair_compare(x, reference = "official", sensor = "citizen")
plot(comparison)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/comparisons.R
\name{plot.citizenair_comparison_ircel}
\alias{plot.citizenair_comparison_ircel}
\title{Plot functionality for an object of class \code{citizenair_comparison_ircel} as returned by \code{citizenair_compare}}
\usage{
\method{plot}{citizenair_comparison_ircel}(x, ...)
}
\arguments{
\item{x}{an object of class \code{citizenair_comparison_ircel} as returned by \code{\link{citizenair_compare}}}
\item{...}{further arguments, currently not used yet}
}
\description{
Plot functionality for an object of class \code{citizenair_comparison_ircel} as returned by \code{\link{citizenair_compare}}
}
\examples{
library(ggplot2)
x <- data.frame(
time = rep(seq.Date(from = Sys.Date()-364, to = Sys.Date(), by = "day"), 2),
group = sample(c("official", "citizen"), size = 365*2, replace = TRUE),
value = rnorm(365*2))
comparison <- citizenair_compare(x, reference = "official", sensor = "citizen")
plot(comparison)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment