subset.egor | R Documentation |
Functions to index and take subsets of egor()
objects: manipulate
egos, alters, or alter-alter ties.
## S3 method for class 'egor'
subset(x, subset, ..., unit = attr(x, "active"))
## S3 method for class '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 |
Removing or duplicating an ego will also remove or duplicate their alters and ties.
An egor()
object.
# Generate a small sample dataset
(e <- make_egor(5,4))
# First three egos in the dataset
e[1:3,]
# 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)
# Filter egos
subset(x = egor32, subset = egor32$ego$variables$sex == "m", unit="ego")
subset(x = egor32, sex == "m")
# Filter alters
subset(x = egor32, sex == "m", unit = "alter")
# Filter aaties
subset(x = egor32, weight != 0, unit = "aatie")
# Filter egos by alter variables (keep only egos that have more than 13 alters)
subset(x = egor32, nrow(alter) > 13, unit = "alter")
# Filter alters by ego variables (keep only alters that have egos from Poland)
subset(x = egor32, ego$country == "Poland", unit = "ego")
# Filter edges by alter variables (keep only edges between alters where `sex == "m"`)
subset(x = egor32, all(alter$sex == "m"), unit = "aatie")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.