make.popup.d | R Documentation |
Takes raw values and what percentiles they are at, and presents those as a text field to be used as the text in a popup window on a map
make.popup.d(d, pctile, prefix = "pctile.text.", basenames)
d |
raw demographic values, 0-1 (such as 0.3345 where roughly 33 percent of the local population is under age 5) |
pctile |
required integers 0 to 100, representing the percentile(s) at which the raw value(s) fall(s). |
prefix |
optional, default is 'pctile.text.' This is a text string specifying the first part of the desired resulting fieldname in outputs. |
basenames |
optional, default is colnames(d). Defines colname(s) of outputs, which are the prefix plus this. |
Note d should be a (vector? or) data.frame of exact demographic percentages from 0 to 1, not 0 to 100 BUT pctile should be INTEGER 0 to 100, NOT 0 to 1! Because that is how EJSCREEN data are stored In EJSCREEN, there are three types of pctile.text fields: E (text varies), D, EJ: 'pctile.text.cancer' "55 lifetime risk per million (91 'pctile.text.pctmin' "13 'pctile.text.EJ.DISPARITY.cancer.eo' "36
Returns character vector or data.frame, same shape as first input parameter.
make.popup.d
make.popup.e
make.popup.ej
pctileAsText
# inputs are test0 and test1, and desired output is like test2
# (except note how prefix is added to each basename)
test0 <- structure(list(
VSI.eo = c(0.185525372063833, 0.174428104575163, 0.485647788983707),
pctmin = c(0.131656804733727, 0.111928104575163, 0.671062839410395),
other = c(NA, NA, 0.02)),
.Names = c("VSI.eo", "pctmin", "other"),
row.names = c(NA, 3L), class = "data.frame")
test0
# VSI.eo pctmin other
# 1 0.1855254 0.1316568 NA
# 2 0.1744281 0.1119281 NA
# 3 0.4856478 0.6710628 0.02
test1 <- structure(list(
pctile.VSI.eo = c(27.1991395138354, 24.6836238179206, 72.382419748292),
pctile.pctmin = c(30.2662374847936, 26.761078397073, 78.2620665123235),
other = c(NA, NA, 4)),
.Names = c("pctile.VSI.eo", "pctile.pctmin", "other"),
row.names = c(NA, 3L), class = "data.frame")
test1
# pctile.VSI.eo pctile.pctmin other
# 1 27.19914 30.26624 NA
# 2 24.68362 26.76108 NA
# 3 72.38242 78.26207 4
test2 <- structure(list(
pctile.text.VSI.eo = c("19% (27%ile)", "17% (24%ile)","49% (72%ile)"),
pctile.text.pctmin = c("13% (30%ile)", "11% (26%ile)", "67% (78%ile)"),
other = c(NA, NA, 4)),
.Names = c("pctile.text.VSI.eo","pctile.text.pctmin", "other"),
row.names = c(NA, 3L), class = "data.frame")
test2
# pctile.text.VSI.eo pctile.text.pctmin other
# 1 19% (27%ile) 13% (30%ile) NA
# 2 17% (24%ile) 11% (26%ile) NA
# 3 49% (72%ile) 67% (78%ile) 4
make.popup.d(test0, test1)
# pctile.text.VSI.eo pctile.text.pctmin pctile.text.other
# 1 19% (27%ile) 13% (30%ile) <NA>
# 2 17% (24%ile) 11% (26%ile) <NA>
# 3 49% (72%ile) 67% (78%ile) 2% (4%ile)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.