Learn R Programming

mapping (version 1.4.1)

FR: Object of class FR

Description

Creates an object with data and coordinates of class FR for France statistical units to use with mapping functions or available in other R "maps" packages.

Usage

FR(data, colID = NULL, unit = c("region"), 
   year = c("2021", "2020", "2019"), matchWith = c("name", "code"), 
   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)

Value

An object of class FR, with data and coordinates to use in functions which perform map.

Arguments

data

a data.frame object with variables to display

colID

character value or columns number indicating the column with unit names or codes

unit

the type of Italian statistical unit

year

year of the analysis

matchWith

the type of id to check:

"name"if unit names
"code"if unit code

subset

a formula indicating the condition to subset the data, see the Details

add

a formula to add new transformed variables starting from the variables in the data

new_var_names

a character value or vector indicating the names of the new variables created in add

aggregation_fun

function to use when data are aggregated

aggregation_unit

variable name by which the unit are aggregated

aggregation_var

variable name with value to aggregate

facets

variable(s) name to split the data

check.unit.names

a logical value indicating if the colID names are checked with unit names

dir

local directory in which shape files are stored

use_cache

a logical value indicating whether use the cache

print

a logical value indicating whether print the nomatched names

use_internet

a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If FALSE the maps downloaded during package installation will be used

crs

coordinate reference system. Look at st_crs

Details

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").

See Also

EU, WR, US, DE

Examples

Run this code

data("popFR")

# \donttest{

fr <- FR(data = popFR)

### Adding two varaibles


fr2 <- FR(data = popFR,
          add = ~I(population/1000) + I(population/100) )


### Adding to variables and names
fr3 <- FR(data = popFR,
          add = ~I(population/1000) + I(population/100),
          new_var_names = c("ratio1", "ratio2"))
# }


Run the code above in your browser using DataLab