Commit 34aad481 by Jan Wijffels

Move the app

parent ed878e89
--- ---
title: "Citizen Air" title: "Citizen Air"
runtime: shiny runtime: shiny
output: output:
flexdashboard::flex_dashboard: flexdashboard::flex_dashboard:
orientation: columns orientation: columns
...@@ -41,8 +41,6 @@ dashinput$srv <- fetch(services(dashinput$endpoint)) ...@@ -41,8 +41,6 @@ dashinput$srv <- fetch(services(dashinput$endpoint))
dashinput$stations <- stations(dashinput$endpoint, service = dashinput$srv) dashinput$stations <- stations(dashinput$endpoint, service = dashinput$srv)
dashinput$stations_sp <- as.SpatialPointsDataFrame(dashinput$stations) dashinput$stations_sp <- as.SpatialPointsDataFrame(dashinput$stations)
dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp), FUN=function(idx) gIntersects(dashinput$region, dashinput$stations_sp[idx, ])), ] dashinput$stations_sp <- dashinput$stations_sp[sapply(1:nrow(dashinput$stations_sp), FUN=function(idx) gIntersects(dashinput$region, dashinput$stations_sp[idx, ])), ]
``` ```
...@@ -60,10 +58,10 @@ popups$cleaned_data <- modalDialog( ...@@ -60,10 +58,10 @@ popups$cleaned_data <- modalDialog(
# Data {data-icon="fa-cloud-upload"} # Data {data-icon="fa-cloud-upload"}
```{r child="pages_citizenair/page01-introduction.Rmd", eval=TRUE} ```{r child="page01-introduction.Rmd", eval=TRUE}
``` ```
# Exploreer en vergelijk {data-icon="fa-toggle-on"} # Exploreer en vergelijk {data-icon="fa-toggle-on"}
```{r child="pages_citizenair/page02-exploratory.Rmd", eval=TRUE} ```{r child="page02-exploratory.Rmd", eval=TRUE}
``` ```
...@@ -83,7 +83,7 @@ output$uiOutput_stations <- renderLeaflet({ ...@@ -83,7 +83,7 @@ output$uiOutput_stations <- renderLeaflet({
map <- addCircleMarkers(map = map, data = stations, radius = 5, opacity = 0.3, fillOpacity = 1, weight = 3, popup = as.character(stations$label)) map <- addCircleMarkers(map = map, data = stations, radius = 5, opacity = 0.3, fillOpacity = 1, weight = 3, popup = as.character(stations$label))
if(length(userdata$nearest_station) > 0){ if(length(userdata$nearest_station) > 0){
stations <- subset(stations, id %in% userdata$nearest_station) stations <- subset(stations, id %in% userdata$nearest_station)
map <- addPopups(map, data = stations, popup = "Dichtstbijzijnde officiële meetstation") map <- addPopups(map, data = stations, popup = "Dichtstbijzijnd gevalideerd meetstation")
} }
if(nrow(meta) > 0){ if(nrow(meta) > 0){
map <- addPopups(map, lng = meta$lon, lat = meta$lat, popup = "Uw meetpunten") map <- addPopups(map, lng = meta$lon, lat = meta$lat, popup = "Uw meetpunten")
...@@ -171,13 +171,16 @@ renderTable({ ...@@ -171,13 +171,16 @@ renderTable({
userdata <- citizenair_userdata() userdata <- citizenair_userdata()
x <- as.data.table(userdata$data$phenomena) x <- as.data.table(userdata$data$phenomena)
if(nrow(x) > 0){ if(nrow(x) > 0){
x <- x[, frequentie := as.numeric(difftime(timepoint, shift(timepoint, type = "lag", n = 1L), units = "mins")), x <- x[, meetfrequentie := as.numeric(difftime(timepoint, shift(timepoint, type = "lag", n = 1L), units = "mins")),
by = list(sheet_id)] by = list(sheet_id)]
x <- x[!is.na(frequentie), list(n = .N), by = list(sheet_id, frequentie)] x <- x[, list(n = .N), by = list(sheet_id, meetfrequentie)]
x <- x[, pct := round(100 * n / sum(n), 1), by = list(sheet_id)]
x <- subset(x, !is.na(meetfrequentie))
x <- x[order(n, decreasing=TRUE), ] x <- x[order(n, decreasing=TRUE), ]
x <- merge(x, userdata$data$meta, by = "sheet_id") x <- merge(x, userdata$data$meta, by = "sheet_id")
x <- as.data.frame(x) x <- as.data.frame(x)
x <- x[!duplicated(x$sheet_id), c("sheet_id", "device", "frequentie")] x <- x[!duplicated(x$sheet_id), c("sheet_id", "device", "meetfrequentie", "n", "pct")]
x$meetfrequentie <- sprintf("elke %s minuten", round(x$meetfrequentie, 2))
}else{ }else{
x <- NULL x <- NULL
} }
......
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