This accessor extracts variables from the locations data frame in an epiflow object. get_vars is a generic with a method defined for epiflows objects.

get_vars(x, ...)

# S3 method for epiflows
get_vars(x, what = NULL, id = TRUE,
  vector = FALSE, ...)

set_vars(x, ...)

set_vars(x, name) <- value

# S3 method for epiflows
set_vars(x, ...)

# S3 method for epiflows
set_vars(x, name) <- value

Arguments

x

An epiflows object.

...

For set_vars(), any number of variables defined in global_vars() that can be used for mapping or modelling. This is unused in get_vars()

what

a valid character string specifying the variable desired. If `NULL` (default), the names of the available vars will be returned.

id

a logical. If `TRUE` (default), the `id` column of the locations will be the first column of the data frame. if `FALSE`, the variable will be returned with identifiers as row names.

vector

if `TRUE` the result will be coerced into a vector (or a matrix in the case of coordinates)

name

the name of the variable in global_vars() to assign

value

the name of the column in the locations data

Value

A data frame with the variables requested

See also

Examples

data("Brazil_epiflows") get_vars(Brazil_epiflows) # defined global variables pointint to column names
#> $pop_size #> [1] "location_population" #> #> $duration_stay #> [1] "length_of_stay" #> #> $num_cases #> [1] "num_cases_time_window" #> #> $first_date #> [1] "first_date_cases" #> #> $last_date #> [1] "last_date_cases" #>
get_vars(Brazil_epiflows, "duration_stay")
#> id length_of_stay #> 1 Espirito Santo NA #> 2 Minas Gerais NA #> 3 Rio de Janeiro NA #> 4 Sao Paulo NA #> 5 Southeast Brazil NA #> 6 Argentina 10.9 #> 7 Chile 10.3 #> 8 Germany 22.3 #> 9 Italy 30.1 #> 10 Paraguay 7.3 #> 11 Portugal 27.2 #> 12 Spain 27.2 #> 13 United Kingdom 19.5 #> 14 United States of America 18.5 #> 15 Uruguay 8.0
get_vars(Brazil_epiflows, "duration_stay", vector = TRUE)
#> Espirito Santo Minas Gerais Rio de Janeiro #> NA NA NA #> Sao Paulo Southeast Brazil Argentina #> NA NA 10.9 #> Chile Germany Italy #> 10.3 22.3 30.1 #> Paraguay Portugal Spain #> 7.3 27.2 27.2 #> United Kingdom United States of America Uruguay #> 19.5 18.5 8.0