An epiflows object inherits the epicontacts class, so the subsetting mechanism is also inherited. The benefits is that it's extremely flexible. However, this also means that it's possible for the contacts to contain IDs that are not present in the locations metadata and vice versa. The best way to consistently subset an epiflows object is present in the examples.

# S3 method for epiflows
[(x, i, j, k = TRUE, l = TRUE, ...)

Arguments

x

An epiflows object.

i

An integer, logical, or character vector of one or more location.

j

An integer, logical, or character vector to subset the flows data frame.

k

A character vector of one or more columns to be retained in the location data.

l

A character vector of one or more columns to be retained in the flows data frame. Note: if using numbers, the first column stands for the first column after "n".

...

Additional parameters passed to [.epicontacts.

Value

An epiflows object.

Details

Returns a subset of an epiflows object.

Examples

data(Brazil_epiflows) # You can subset, but the flows information will still be present Brazil_epiflows[j = "Espirito Santo"]
#> #> /// Epidemiological Flows // #> #> // class: epiflows, epicontacts #> // 15 locations; 20 flows; directed #> // optional variables: pop_size, duration_stay, num_cases, first_date, last_date #> #> // locations #> #> # A tibble: 15 x 6 #> id location_popula… num_cases_time_… first_date_cases last_date_cases #> <chr> <dbl> <dbl> <fct> <fct> #> 1 Espi… 3973697 2600 2017-01-04 2017-04-30 #> 2 Mina… 20997560 4870 2016-12-19 2017-04-20 #> 3 Rio … 16635996 170 2017-02-19 2017-05-10 #> 4 Sao … 44749699 200 2016-12-17 2017-04-20 #> 5 Sout… 86356952 7840 2016-12-17 2017-05-10 #> 6 Arge… NA NA <NA> <NA> #> 7 Chile NA NA <NA> <NA> #> 8 Germ… NA NA <NA> <NA> #> 9 Italy NA NA <NA> <NA> #> 10 Para… NA NA <NA> <NA> #> 11 Port… NA NA <NA> <NA> #> 12 Spain NA NA <NA> <NA> #> 13 Unit… NA NA <NA> <NA> #> 14 Unit… NA NA <NA> <NA> #> 15 Urug… NA NA <NA> <NA> #> # ... with 1 more variable: length_of_stay <dbl> #> #> // flows #> #> # A tibble: 20 x 3 #> from to n #> <chr> <chr> <dbl> #> 1 Espirito Santo Italy 2828. #> 2 Espirito Santo Spain 3270. #> 3 Espirito Santo Portugal 3264. #> 4 Espirito Santo Germany 1898. #> 5 Espirito Santo United Kingdom 1985. #> 6 Espirito Santo United States of America 13597. #> 7 Espirito Santo Argentina 5899. #> 8 Espirito Santo Chile 2794. #> 9 Espirito Santo Uruguay 2630. #> 10 Espirito Santo Paraguay 1164. #> 11 Italy Espirito Santo 1566. #> 12 Spain Espirito Santo 1171. #> 13 Portugal Espirito Santo 1258. #> 14 Germany Espirito Santo 1741. #> 15 United Kingdom Espirito Santo 1467. #> 16 United States of America Espirito Santo 4464. #> 17 Argentina Espirito Santo 16125. #> 18 Chile Espirito Santo 2375. #> 19 Uruguay Espirito Santo 2073. #> 20 Paraguay Espirito Santo 2340. #>
# To help with this, use `thin` from epiflows epicontacts::thin(Brazil_epiflows[j = "Espirito Santo"])
#> #> /// Epidemiological Flows // #> #> // class: epiflows, epicontacts #> // 11 locations; 20 flows; directed #> // optional variables: pop_size, duration_stay, num_cases, first_date, last_date #> #> // locations #> #> # A tibble: 11 x 6 #> id location_popula… num_cases_time_… first_date_cases last_date_cases #> <chr> <dbl> <dbl> <fct> <fct> #> 1 Espi… 3973697 2600 2017-01-04 2017-04-30 #> 2 Arge… NA NA <NA> <NA> #> 3 Chile NA NA <NA> <NA> #> 4 Germ… NA NA <NA> <NA> #> 5 Italy NA NA <NA> <NA> #> 6 Para… NA NA <NA> <NA> #> 7 Port… NA NA <NA> <NA> #> 8 Spain NA NA <NA> <NA> #> 9 Unit… NA NA <NA> <NA> #> 10 Unit… NA NA <NA> <NA> #> 11 Urug… NA NA <NA> <NA> #> # ... with 1 more variable: length_of_stay <dbl> #> #> // flows #> #> # A tibble: 20 x 3 #> from to n #> <chr> <chr> <dbl> #> 1 Espirito Santo Italy 2828. #> 2 Espirito Santo Spain 3270. #> 3 Espirito Santo Portugal 3264. #> 4 Espirito Santo Germany 1898. #> 5 Espirito Santo United Kingdom 1985. #> 6 Espirito Santo United States of America 13597. #> 7 Espirito Santo Argentina 5899. #> 8 Espirito Santo Chile 2794. #> 9 Espirito Santo Uruguay 2630. #> 10 Espirito Santo Paraguay 1164. #> 11 Italy Espirito Santo 1566. #> 12 Spain Espirito Santo 1171. #> 13 Portugal Espirito Santo 1258. #> 14 Germany Espirito Santo 1741. #> 15 United Kingdom Espirito Santo 1467. #> 16 United States of America Espirito Santo 4464. #> 17 Argentina Espirito Santo 16125. #> 18 Chile Espirito Santo 2375. #> 19 Uruguay Espirito Santo 2073. #> 20 Paraguay Espirito Santo 2340. #>
epicontacts::thin(Brazil_epiflows[j = c("Espirito Santo", "Rio de Jenerio")])
#> #> /// Epidemiological Flows // #> #> // class: epiflows, epicontacts #> // 11 locations; 20 flows; directed #> // optional variables: pop_size, duration_stay, num_cases, first_date, last_date #> #> // locations #> #> # A tibble: 11 x 6 #> id location_popula… num_cases_time_… first_date_cases last_date_cases #> <chr> <dbl> <dbl> <fct> <fct> #> 1 Espi… 3973697 2600 2017-01-04 2017-04-30 #> 2 Arge… NA NA <NA> <NA> #> 3 Chile NA NA <NA> <NA> #> 4 Germ… NA NA <NA> <NA> #> 5 Italy NA NA <NA> <NA> #> 6 Para… NA NA <NA> <NA> #> 7 Port… NA NA <NA> <NA> #> 8 Spain NA NA <NA> <NA> #> 9 Unit… NA NA <NA> <NA> #> 10 Unit… NA NA <NA> <NA> #> 11 Urug… NA NA <NA> <NA> #> # ... with 1 more variable: length_of_stay <dbl> #> #> // flows #> #> # A tibble: 20 x 3 #> from to n #> <chr> <chr> <dbl> #> 1 Espirito Santo Italy 2828. #> 2 Espirito Santo Spain 3270. #> 3 Espirito Santo Portugal 3264. #> 4 Espirito Santo Germany 1898. #> 5 Espirito Santo United Kingdom 1985. #> 6 Espirito Santo United States of America 13597. #> 7 Espirito Santo Argentina 5899. #> 8 Espirito Santo Chile 2794. #> 9 Espirito Santo Uruguay 2630. #> 10 Espirito Santo Paraguay 1164. #> 11 Italy Espirito Santo 1566. #> 12 Spain Espirito Santo 1171. #> 13 Portugal Espirito Santo 1258. #> 14 Germany Espirito Santo 1741. #> 15 United Kingdom Espirito Santo 1467. #> 16 United States of America Espirito Santo 4464. #> 17 Argentina Espirito Santo 16125. #> 18 Chile Espirito Santo 2375. #> 19 Uruguay Espirito Santo 2073. #> 20 Paraguay Espirito Santo 2340. #>