WR
Creates an object with data and coordinate of class WR
to use with mapping
function or available in other R "maps" packages.
WR(data, colID = NULL,
unit = c("country", "nato", "ocde", "continent",
"region", "subregion", "region_wb",
"type_income", "type_economy"),
matchWith = c("country", "iso2", "iso3", "iso3_eh",
"iso3_numeric", "iso3_un", "iso2_wb",
"iso3_wb", "name_formal", "name_wb"),
res = c("low", "hi"), show_wr = TRUE, subset = NULL,
add = NULL, new_var_names = NULL,
aggregation_fun = sum, aggregation_unit = NULL, aggregation_var = NULL,
facets = NULL, check.unit.names = TRUE, dir = NULL, use_cache = TRUE,
print = FALSE, use_internet = TRUE, crs = NULL)
a data.frame object with variables to display
character value or columns number indicating the column with unit names
the type of world statistical unit
the type of id to check:
"country" |
if country names |
"iso2" |
if iso2 code |
"iso3" |
if iso3 code |
"iso3_eh" |
if iso3_eh code |
"iso3_numeric" |
if iso3 numeric code |
"iso3_un" |
if iso3 United Nations |
"iso2_wb" |
if iso2 World Bank |
"iso3_wb" |
if iso3 World Bank |
"name_formal" |
if formal names |
map resolution
logical value set to TRUE indicating if the entire map is drawn or only the coordinates linked to the input data
a formula indicating the condition to subset the data, see the Details
a formula to add new transformed variables starting from the variables in the data
a character value or vector indicating the names of the new variables created in add
function to use when data are aggregated
variable name by which the unit are aggregated
variable name with value to aggregate
variable(s) name to split the data
a logical value indicating if the colID
names are checked with unit
names
local directory in which shape files are stored
a logical value indicating whether use the cache
a logical value indicating whether print the nomatched names
a logical value indicating wheter the coordinates are downloaded from https://github.com/dataallaround/geospatial. If FALSE
the maps downloaded during package installation will be used
coordinate reference system. Look at st_crs
An object of class WR
, with data and coordinates to use in functions which perform map.
The function links (automatically) the id in the data
and the coordinates for the given unit
.
Since the names (or codes) provided in the data
given in input must be checked with the unit
names (or codes) available in the package, the check.unit.names
provides a preliminary check.
subset
provide an expression to subset the data
, using a formula with the logical operators. For example, sub-samples of the data can be selected as follows: ~I("Variable 1" == "condition 1" & "Variable 2" != "condition 2")
or for example, ~I("Variable 1" > "condition 1" | "Variable 2" != "condition 2")
.
# NOT RUN {
data("popWR")
wr <- WR(data = popWR, colID = "country_code",
matchWith = "iso3_eh", res = "low")
str(wr, 1)
wr1 <- WR(data = popWR, colID = "country_code",
matchWith = "iso3_eh", res = "low",
add = ~I(male/total) + I(female/total))
str(wr1)
wr2 <- WR(data = popWR, colID = "country_code",
matchWith = "iso3_eh", res = "low",
add = ~I(male/total) + I(female/total),
new_var_names = c("Per_Male", "Per_Female"))
str(wr2)
# }
Run the code above in your browser using DataLab