-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.R
More file actions
53 lines (42 loc) · 1.62 KB
/
app.R
File metadata and controls
53 lines (42 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##############################
# Uganda 2014 Census Map
##############################
suppressPackageStartupMessages({
library(shiny)
library(shinyBS)
library(collapse) # > 1.8.0
library(leaflet)
library(sf)
library(scales)
library(htmltools)
library(RColorBrewer)
})
# rm(list = ls())
# load("app_DATA.RData")
qs::qreadm("app_DATA.qs", nthreads = 2)
idvars <- c("Region", "District", "County", "Subcounty", "Parish")
names(cens_vars_list)[1L] <- "Composite Indices"
agglabs <- setNames(idvars, paste0(idvars, " (",
c(fnrow(DATA_Region), fnrow(DATA_District), fnrow(DATA_County),
fnrow(DATA_Subcounty), fnrow(DATA)), ")"))
# rsconnect::showLogs()
# Todo: still accomodate per area !
genpopup <- function(data, colvar = "POP_M", oth = c("POP", "HDI"),
idvars = c("Region", "District", "County", "Subcounty", "Parish")) { # , coldata
ids <- idvars[idvars %in% names(data)]
if(colvar %!in% oth) oth <- c(oth, colvar)
vars <- c(ids, oth)
lhs <- paste0("<br/><strong>", vars, ":</strong>")
lhs[1L] <- substr(lhs[1L], 6L, 10000L)
pop <- c(as.vector(lhs, "list"), .subset(data, vars))
if(length(nint <- vtypes(pop[oth], FALSE) %!=% "integer"))
pop[oth][nint] <- lapply(pop[oth][nint], round, 3L)
o <- seq(1L, 2L*length(vars), 2L)
o <- radixorder(c(o, o + 1L))
do.call(paste, pop[o]) # lapply(, htmltools::HTML)
}
ui <- source(file.path("geoUI.R"), local = TRUE)$value
server <- function(input, output, session) {
source(file.path("geoSERVER.R"), local = TRUE)$value
}
shinyApp(ui = ui, server = server)