Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
citizenair
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vmm
citizenair
Commits
1d9b2d35
Commit
1d9b2d35
authored
Nov 07, 2018
by
Jan Wijffels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple graph
parent
b4bff142
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
6 deletions
+31
-6
README.md
+1
-1
citizenair-shinyproxy/Dockerfile
+1
-1
citizenair/R/appdata.R
+8
-0
citizenair/inst/apps/citizenair/citizenair.Rmd
+4
-2
citizenair/inst/apps/citizenair/page01-introduction.Rmd
+2
-1
citizenair/inst/apps/citizenair/page02-exploratory.Rmd
+10
-1
citizenair/man/CitizenAir.Rd
+5
-0
No files found.
README.md
View file @
1d9b2d35
...
...
@@ -22,7 +22,7 @@ run_app('citizenair.Rmd')
install.packages
(
c
(
'flexdashboard'
,
'shiny'
,
'shinyWidgets'
,
'rmarkdown'
,
'DT'
))
install.packages
(
c
(
'data.table'
,
'httr'
,
'readxl'
,
'magrittr'
,
'cellranger'
,
'fasttime'
))
install.packages
(
c
(
'leaflet'
,
'sp'
,
'rgeos'
))
install.packages
(
c
(
'dygraphs'
))
install.packages
(
c
(
'dygraphs'
,
'xts'
))
devtools
::
install_github
(
'bnosac/BelgiumMaps.Statbel'
)
devtools
::
install_github
(
'52North/sensorweb4R'
)
devtools
::
install_git
(
'https://www.datatailor.be/vmm/citizenair'
,
subdir
=
'citizenair'
)
...
...
citizenair-shinyproxy/Dockerfile
View file @
1d9b2d35
...
...
@@ -6,7 +6,7 @@ RUN R -e "install.packages(c('devtools'), repos='https://cloud.r-project.org/')"
RUN
R
-e
"install.packages(c('flexdashboard', 'shiny', 'shinyWidgets', 'rmarkdown', 'DT'), repos='https://cloud.r-project.org/')"
RUN
R
-e
"install.packages(c('data.table', 'httr', 'readxl', 'magrittr', 'cellranger', 'fasttime'), repos='https://cloud.r-project.org/')"
RUN
R
-e
"install.packages(c('leaflet', 'sp', 'rgeos'), repos='https://cloud.r-project.org/')"
RUN
R
-e
"install.packages(c('dygraphs'), repos='https://cloud.r-project.org/')"
RUN
R
-e
"install.packages(c('dygraphs'
, 'xts'
), repos='https://cloud.r-project.org/')"
RUN
R
-e
"devtools::install_github('bnosac/BelgiumMaps.Statbel')"
RUN
R
-e
"devtools::install_github('52North/sensorweb4R')"
RUN
git
-c
http.sslVerify
=
false
clone https://www.datatailor.be/vmm/citizenair
...
...
citizenair/R/appdata.R
View file @
1d9b2d35
...
...
@@ -39,14 +39,19 @@ citizenair_userdata_empty <- function(){
#' ca
#' ca$getPhenomena()
#'
#' ## get stations
#' library(sp)
#' x <- ca$getStations()
#' plot(x)
#'
#' ## get official measurements
#' library(lubridate)
#' x <- ca$fetch_timeseries(id = "1030")
#' period <- as.interval(as.POSIXct(Sys.Date() - 14), Sys.time())
#' x <- ca$fetch_timeseries(id = "1030", time_span = period)
#' ## set citizen measurements
#' filename <- system.file(package = "citizenair", "data-raw", "citizenair-example.xls")
#' ca$setCitizenData(filename)
CitizenAir
<-
R
6
::
R
6
Class
(
"CitizenAir"
,
public
=
list
(
endpoint
=
NULL
,
...
...
@@ -104,6 +109,9 @@ CitizenAir <- R6::R6Class("CitizenAir",
},
getPhenomena
=
function
(){
self
$
stations
$
phenomena
$
id
},
setCitizenData
=
function
(
file
,
name
=
basename
(
file
)){
self
$
data
<-
read_citizenair
(
file
)
}
),
private
=
list
()
...
...
citizenair/inst/apps/citizenair/citizenair.Rmd
View file @
1d9b2d35
...
...
@@ -23,13 +23,15 @@ library(rgeos)
library(citizenair)
library(DT)
library(sp)
library(xts)
library(dygraphs)
data("BE_ADMIN_REGION", package = "BelgiumMaps.StatBel")
dashinput <- list()
dashinput$endpoint <- as.Endpoint("http://geo.irceline.be/sos/api/v1")
dashinput$
c
a <- CitizenAir$new(endpoint = dashinput$endpoint)
dashinput$
appdat
a <- CitizenAir$new(endpoint = dashinput$endpoint)
dashinput$region <- subset(BE_ADMIN_REGION, TX_RGN_DESCR_NL %in% "Vlaams Gewest")
dashinput$stations_sp <- dashinput$
c
a$getStations()
dashinput$stations_sp <- dashinput$
appdat
a$getStations()
dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp),
FUN=function(idx) gIntersects(dashinput$region, dashinput$stations_sp[idx, ])), ]
```
...
...
citizenair/inst/apps/citizenair/page01-introduction.Rmd
View file @
1d9b2d35
...
...
@@ -44,10 +44,11 @@ citizenair_userdata <- reactive({
result$file <- default
}else{
showNotification("We lezen uw Excel bestand in wacht even...")
x <- try(
read_citizenair
(result$file))
x <- try(
dashinput$appdata$setCitizenData
(result$file))
if(inherits(x, "try-error")){
showNotification(sprintf("Er loopt iets fout, is uw data bestand wel een correct bestand? %s", as.character(attributes(x)$condition)))
}else{
x <- dashinput$appdata$data
result$data$polluenten <- x$phenomena
result$data$meta <- as.data.frame(x, type = "meta")
result$data$phenomena <- as.data.frame(x, type = "measurements")
...
...
citizenair/inst/apps/citizenair/page02-exploratory.Rmd
View file @
1d9b2d35
...
...
@@ -3,7 +3,16 @@
### Toon je metingen
gemiddelde / mediaan / piek / dal
```{r}
x <- dashinput$appdata$fetch_timeseries("1030")
x <- setDT(x)
ts <- dcast.data.table(data = x, formula = time ~ phenomena_label, fun.aggregate = mean, value.var = "value")
ts <- setDF(ts)
g <- xts(ts[, -1], order.by=ts[,1])
g <- dygraph(g, main = "Tijdreeks van 1030 - Under construction")
g <- dyRangeSelector(g, height = 20)
g
```
### Vergelijk met officiële metingen
...
...
citizenair/man/CitizenAir.Rd
View file @
1d9b2d35
...
...
@@ -36,13 +36,18 @@ ca <- CitizenAir$new(e)
ca
ca$getPhenomena()
## get stations
library(sp)
x <- ca$getStations()
plot(x)
## get official measurements
library(lubridate)
x <- ca$fetch_timeseries(id = "1030")
period <- as.interval(as.POSIXct(Sys.Date() - 14), Sys.time())
x <- ca$fetch_timeseries(id = "1030", time_span = period)
## set citizen measurements
filename <- system.file(package = "citizenair", "data-raw", "citizenair-example.xls")
ca$setCitizenData(filename)
}
\keyword{datasets}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment