Commit 645492db by Jan Wijffels

Add the R package

parent ab43a150
......@@ -15,11 +15,12 @@ Aan het werk
```r
## Install packages
install.packages(c("flexdashboard", "shiny", "shinyWidgets", "rmarkdown"))
install.packages(c("flexdashboard", "shiny", "shinyWidgets", "rmarkdown", "DT"))
install.packages(c("data.table", "httr", "readxl", "magrittr"))
install.packages(c("leaflet", "sp", "rgeos", "magrittr"))
devtools::install_github("bnosac/BelgiumMaps.Statbel")
devtools::install_github("52North/sensorweb4R")
devtools::install_git("https://www.datatailor.be/vmm/citizenair", subdir = "citizenair")
## Run the app
rmarkdown::run("apps/citizenair.Rmd")
......
......@@ -11,3 +11,9 @@ Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
BuildType: Package
PackageUseDevtools: Yes
PackagePath: citizenair
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Package: citizenair
Type: Package
Title: Citizen Air Analysis Utilities
Version: 0.1
Maintainer: Jan Wijffels <jwijffels@bnosac.be>
Authors@R: c(
person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = 'jwijffels@bnosac.be'),
person('BNOSAC', role = 'cph'))
Description: Utilities for the Citizen Air application.
License: CC-BY-SA-4.0
RoxygenNote: 6.0.1
Imports: readxl, cellranger, data.table, fasttime
Suggests: sp
# Generated by roxygen2: do not edit by hand
S3method(as.data.frame,citizenair)
export(read_citizenair)
importFrom(cellranger,cell_cols)
importFrom(cellranger,cell_limits)
importFrom(cellranger,cell_rows)
importFrom(data.table,as.data.table)
importFrom(data.table,melt.data.table)
importFrom(data.table,rbindlist)
importFrom(data.table,setnames)
importFrom(fasttime,fastPOSIXct)
importFrom(readxl,excel_sheets)
importFrom(readxl,read_excel)
importFrom(utils,capture.output)
importFrom(utils,head)
importFrom(utils,tail)
#' @importFrom readxl read_excel excel_sheets
#' @importFrom cellranger cell_rows cell_cols cell_limits
#' @importFrom utils head tail capture.output
#' @importFrom data.table rbindlist melt.data.table setnames as.data.table
#' @importFrom fasttime fastPOSIXct
NULL
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read-citizendata.R
\name{as.data.frame.citizenair}
\alias{as.data.frame.citizenair}
\title{Convert excel data to a data.frame}
\usage{
\method{as.data.frame}{citizenair}(x, row.names, optional, ...,
type = c("meta", "measurements"))
}
\arguments{
\item{x}{an object of class \code{citizenair} as returned by \code{\link{read_citizenair}}}
\item{row.names}{not used}
\item{optional}{not used}
\item{...}{not used}
\item{type}{either 'meta' to get the meta information as a data.frame or 'measurements' to get the measurements data.frame}
}
\value{
a data.frame is returned
\enumerate{
\item{in case type is meta: contains fields sheet_id, sheet, device, lat, lon, phenomena}
\item{in case type is data: contains fields sheet_id, timepoint, date, phenomena, value}
}
}
\description{
Convert excel data to a data.frame
}
\examples{
filename <- system.file(package = "citizenair", "data-raw", "test_dummy.xls")
x <- read_citizenair(filename)
meta <- as.data.frame(x, type = "meta")
measurements <- as.data.frame(x, type = "measurements")
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read-citizendata.R
\name{read_citizenair}
\alias{read_citizenair}
\title{Read in a CitizenAir excel file}
\usage{
read_citizenair(file = system.file(package = "citizenair", "data-raw",
"test_dummy.xls"), name = basename(file))
}
\arguments{
\item{file}{the path to the excel file}
\item{name}{the name of the file, defaults to the basename of the file}
}
\value{
an object of class \code{citizenair} which is a list with elements
\enumerate{
\item{filename: the name of the file}
\item{file: the full path to the excel file}
\item{time: the timestamp when the data was imported}
\item{content: a list where each list element contains the elements meta and data where meta and data are described below}
}
Content element meta is a list containing
\enumerate{
\item{device: the name of the device}
\item{lat: the latitude of the device address}
\item{lon: the longitude of the device address}
\item{sheet_id: an identifier which is the sequence number of the sheet}
\item{sheet: the sheet name which was read in}
\item{phenomena: a list containing phenomena measured in the data. Each list element is a character vector with the measurement unit.}
}
Content element data is a data.frame with the measurements containing
\enumerate{
\item{datum: the date - in POSIXct format returned by readxl::read_excel when setting that field to date}
\item{time: the time - in POSIXct format returned by readxl::read_excel when setting that field to date}
\item{several columns, one for each phenomena indicated in the \code{meta} element}
}
}
\description{
Read in a CitizenAir excel file
}
\examples{
filename <- system.file(package = "citizenair", "data-raw", "test_dummy.xls")
x <- read_citizenair(filename)
meta <- as.data.frame(x, type = "meta")
measurements <- as.data.frame(x, type = "measurements")
}
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