You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the example in the doc, I am not sure if the function is working, or I misunderstand it's use. In the example below, the number of cases in the linelist changes, but contacts remains unchanged.
if (require(outbreaks)) {
+ ## build data
+ x <- make_epicontacts(ebola_sim$linelist, ebola_sim$contacts,
+ id="case_id", to="case_id", from="infector",
+ directed=TRUE)
+
+
+ id <- "cac51e" ## it can be a vector of id as well
+
+
+ ## subset based on cluster to which "cac51e" belongs
+ x_subset <- subset_clusters_by_id(x, id)
+
+ }
Loading required package: outbreaks
>
> x
/// Epidemiological Contacts //
// class: epicontacts
// 5,888 cases in linelist; 3,800 contacts; directed
// linelist
# A tibble: 5,888 x 11
id generation date_of_infecti… date_of_onset date_of_hospita…
<chr> <int> <date> <date> <date>
1 d1fa… 0 NA 2014-04-07 2014-04-17
2 5337… 1 2014-04-09 2014-04-15 2014-04-20
3 f5c3… 1 2014-04-18 2014-04-21 2014-04-25
4 6c28… 2 NA 2014-04-27 2014-04-27
5 0f58… 2 2014-04-22 2014-04-26 2014-04-29
6 4973… 0 2014-03-19 2014-04-25 2014-05-02
7 f914… 3 NA 2014-05-03 2014-05-04
8 881b… 3 2014-04-26 2014-05-01 2014-05-05
9 e66f… 2 NA 2014-04-21 2014-05-06
10 20b6… 3 NA 2014-05-05 2014-05-06
# … with 5,878 more rows, and 6 more variables: date_of_outcome <date>,
# outcome <fct>, gender <fct>, hospital <fct>, lon <dbl>, lat <dbl>
// contacts
# A tibble: 3,800 x 3
from to source
<chr> <chr> <fct>
1 d1fafd 53371b other
2 cac51e f5c3d8 funeral
3 f5c3d8 0f58c4 other
4 0f58c4 881bd4 other
5 8508df 40ae5f other
6 127d83 f547d6 funeral
7 f5c3d8 d58402 other
8 20b688 d8a13d other
9 2ae019 a3c8b8 other
10 20b688 974bc1 other
# … with 3,790 more rows
> x_subset
/// Epidemiological Contacts //
// class: epicontacts
// 5 cases in linelist; 3,800 contacts; directed
// linelist
# A tibble: 5 x 11
id generation date_of_infecti… date_of_onset date_of_hospita…
<chr> <int> <date> <date> <date>
1 f5c3… 1 2014-04-18 2014-04-21 2014-04-25
2 0f58… 2 2014-04-22 2014-04-26 2014-04-29
3 881b… 3 2014-04-26 2014-05-01 2014-05-05
4 d584… 2 2014-04-23 2014-05-01 2014-05-10
5 9000… 3 2014-05-09 2014-05-14 2014-05-17
# … with 6 more variables: date_of_outcome <date>, outcome <fct>, gender <fct>,
# hospital <fct>, lon <dbl>, lat <dbl>
// contacts
# A tibble: 3,800 x 3
from to source
<chr> <chr> <fct>
1 d1fafd 53371b other
2 cac51e f5c3d8 funeral
3 f5c3d8 0f58c4 other
4 0f58c4 881bd4 other
5 8508df 40ae5f other
6 127d83 f547d6 funeral
7 f5c3d8 d58402 other
8 20b688 d8a13d other
9 2ae019 a3c8b8 other
10 20b688 974bc1 other
# … with 3,790 more rows
>
The text was updated successfully, but these errors were encountered:
The error was in the last line of the function, which incorrectly subsetted the epicontacts object. It now uses igraph to subset and then rebuild the epicontacts object.
From the example in the doc, I am not sure if the function is working, or I misunderstand it's use. In the example below, the number of cases in the linelist changes, but contacts remains unchanged.
The text was updated successfully, but these errors were encountered: