Description Usage Arguments Examples
View source: R/topogram_select.R
Use in RMarkdown documents to update a topogram()
dynamically.
1 2 3 4 5 6 7 8 9 10 | topogram_select(
topogramId,
sfobj,
values,
label = "{value}",
palette = "viridis",
rescale_to = c(1, 1000),
n_iteration = 10,
width = NULL
)
|
topogramId |
The |
sfobj |
An |
values |
Parameters to construct cartograms, can be:
|
label |
|
palette |
Name of a color palette, such as |
rescale_to |
Rescale value to distort topology to a specified range, use |
n_iteration |
Number of iterations to run the algorithm for. Higher numbers distorts the areas closer to their associated value, at the cost of performance. |
width |
A numeric input in pixels. |
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 53 54 55 56 57 58 59 60 61 62 63 64 | library(topogram)
library(htmltools)
# normally, you would use the following in RMarkdown
browsable(tagList(
# Select menu
topogram_select(
topogramId = "ID",
sfobj = world,
values = list(
"Population" = "pop_est",
"GDP" = "gdp_md_est",
"CO2 emissions (1990)" = "co2_emissions_1990",
"CO2 emissions (2020)" = "co2_emissions_2020",
"Share of electricity production from renewables" = "renewables_percent_electricity"
),
label = "{name} : {value}"
),
# Topogram
topogram(
sfobj = world,
value = "pop_est",
label = "{name} : {value}",
elementId = "ID"
)
), value = interactive())
# specific options according to variables
browsable(tagList(
# Select menu
topogram_select(
topogramId = "ID",
sfobj = world,
values = list(
list(
text = "Population",
value = "pop_est",
palette = "Greens",
label = "{name} : {value} inhabitants"
),
list(
text = "GDP",
value = "gdp_md_est",
palette = "Blues",
label = "{name} : ${value}",
labs = list(title = "GDP", subtitle = "estimate, in 2017")
)
),
label = "{name} : {value}"
),
# Topogram
topogram(
sfobj = world,
value = "pop_est",
elementId = "ID",
# you have to specify parameters for initializing topogram
palette = "Greens",
label = "{name} : {value} inhabitants"
)
), value = interactive())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.