Functions to index and take subsets of egor()
objects: manipulate
egos, alters, or alter-alter ties.
# S3 method for egor subset(x, subset, ..., unit = attr(x, "active")) # S3 method for egor [(x, i, j, unit = attr(x, "active"), ...)
x | an |
---|---|
subset | either an expression evaluated on each of the rows of
the selected unit (as in the eponymous argument of
|
... | extra arguments to |
unit | a selector of the unit of analysis being affected: the
egos, the alters or the (alter-alter) ties. Note that only one
type of unit can be affected at a time. Defaults to the current
active unit selected by |
i | numeric or logical vector indexing the appropriate unit. |
j | either an integer vector specifying which columns of the
filtered structure (ego, alters, or ties) to select, or a logical
vector specifying which columns to keep. Note that the special
columns .egoID, .altID, .srcID, .tgtID are not indexed by |
An egor()
object.
Removing or duplicating an ego will also remove or duplicate their alters and ties.
#> # EGO data (active): 5 x 6 #> .egoID sex age age.years country income #> <dbl> <chr> <fct> <int> <chr> <dbl> #> 1 1 m 66 - 100 82 Poland 45990 #> 2 2 w 18 - 25 24 Australia 11680 #> 3 3 m 66 - 100 83 Poland 36135 #> 4 4 w 66 - 100 100 Poland 34310 #> 5 5 m 56 - 65 60 Australia 32120 #> # ALTER data: 16 x 7 #> .altID .egoID sex age age.years country income #> <int> <dbl> <chr> <fct> <int> <chr> <dbl> #> 1 1 1 w 66 - 100 83 USA 59495 #> 2 2 1 m 66 - 100 73 USA 5475 #> 3 1 2 m 36 - 45 44 Australia 12775 #> # AATIE data: 10 x 4 #> .egoID .srcID .tgtID weight #> <int> <int> <int> <dbl> #> 1 2 1 4 0.333 #> 2 3 1 2 0.667 #> 3 2 3 4 0.333# First three egos in the dataset e[1:3,]#> # EGO data (active): 3 x 6 #> .egoID sex age age.years country income #> <dbl> <chr> <fct> <int> <chr> <dbl> #> 1 1 m 66 - 100 82 Poland 45990 #> 2 2 w 18 - 25 24 Australia 11680 #> 3 3 m 66 - 100 83 Poland 36135 #> # ALTER data: 10 x 7 #> .altID .egoID sex age age.years country income #> <int> <dbl> <chr> <fct> <int> <chr> <dbl> #> 1 1 1 w 66 - 100 83 USA 59495 #> 2 2 1 m 66 - 100 73 USA 5475 #> 3 1 2 m 36 - 45 44 Australia 12775 #> # AATIE data: 6 x 4 #> .egoID .srcID .tgtID weight #> <int> <int> <int> <dbl> #> 1 2 1 4 0.333 #> 2 3 1 2 0.667 #> 3 2 3 4 0.333# Using an external vector # (though normally, we would use e[.keep,] here) .keep <- rep(c(TRUE, FALSE), length.out=nrow(e$ego)) subset(e, .keep)#> # EGO data (active): 3 x 6 #> .egoID sex age age.years country income #> <dbl> <chr> <fct> <int> <chr> <dbl> #> 1 1 m 66 - 100 82 Poland 45990 #> 2 3 m 66 - 100 83 Poland 36135 #> 3 5 m 56 - 65 60 Australia 32120 #> # ALTER data: 8 x 7 #> .altID .egoID sex age age.years country income #> <int> <dbl> <chr> <fct> <int> <chr> <dbl> #> 1 1 1 w 66 - 100 83 USA 59495 #> 2 2 1 m 66 - 100 73 USA 5475 #> 3 1 3 m 0 - 17 16 Australia 45625 #> # AATIE data: 2 x 4 #> .egoID .srcID .tgtID weight #> <int> <int> <int> <dbl> #> 1 3 1 2 0.667 #> 2 3 2 4 0.333