global_vars | R Documentation |
The metadata in locations such as population size, duration of stay in a
given location, date of first and last cases, etc. can be useful in estimating
the risk of spread, but not everyone will code their data with identical column
names. To facilitate their use in the function estimate_risk_spread()
, the
epiflows object stores a dictionary of variables in a place called $vars
.
We can tell epiflows what variables are important when we create the object.
global_vars(..., set = FALSE, reset = FALSE)
... |
quoted varaibles to add to the default variables |
set |
when |
reset |
when |
The default varaibles are:
coordinates
: two columns specifying the lon and lat coordinates
pop_size
: population size of each location
duration_stay
: the average duration of stay for each location
first_date
: the date of first recorded case
last_date
: the date of the last recorded case
num_cases
: the number of cases between the first and last date
make_epiflows()
, get_locations()
, get_vars()
, set_vars()
, get_coordinates()
# see the default varaibles
global_vars()
# Equivalent
getOption("epiflows.vars")
# create an object, specifying these variables
data("YF_locations")
data("YF_flows")
ef <- make_epiflows(flows = YF_flows,
locations = YF_locations,
pop_size = "location_population",
duration_stay = "length_of_stay",
num_cases = "num_cases_time_window",
first_date = "first_date_cases",
last_date = "last_date_cases"
)
ef
# You will receive an error if a variable is specified incorrectly
YF_locations$random_variable <- runif(nrow(YF_locations))
try({
ef <- make_epiflows(flows = YF_flows,
locations = YF_locations,
Pop_size = "location_population",
duration_stay = "length_of_stay",
num_cases = "num_cases_time_window",
first_date = "first_date_cases",
last_date = "last_date_cases",
random = "random_variable"
)
})
# If you create a new method and need other varaibles, or just want a shorter
# representation, they can be added to your options:
global_vars("random", set = TRUE)
YF_locations$random_variable <- runif(nrow(YF_locations))
ef <- make_epiflows(flows = YF_flows,
locations = YF_locations,
pop_size = "location_population",
duration_stay = "length_of_stay",
num_cases = "num_cases_time_window",
first_date = "first_date_cases",
last_date = "last_date_cases",
random = "random_variable"
)
# You can also reset the variables
global_vars(reset = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.