egor
egor copied to clipboard
Remove alters and ties from egor object
Hello,
Perhaps I'm missing something and I checked the documentation but couldn't figure this out yet. Is there any way to remove egos based on some attribute from an egor object after it has been created?
Suppose I create a an egor object using the egor function:
p2p_net <- egor(alters = ego_nets,
egos = main,
aaties = alt_pairs,
ID.vars = list(
ego = "su_id",
alter = "person",
source = "alter1",
target = "alter2"))
The ego_nets
object contains information on the alters and I want to remove all alters from the object if they have attribute1=1
and all other attribute from a set of specified attributes should be zero e.g. attribute2=0
, attribute3=0
, etc.
My current code looks like this:
p2p_net_filtered <- subset(p2p_net,
subset = !(all(
alter$relationship_healthprov == 1 &
rowSums(alter[, c("relationship_spouse", "relationship_partner", "relationship_parent",
"relationship_sibling", "relationship_child", "relationship_grandparent",
"relationship_grandchild", "relationship_relative", "relationship_friend",
"relationship_coworker", "relationship_neighbor", "relationship_roommate",
"relationship_churchmember", "relationship_other")]) == 0)),
unit = "aatie")
This code keeps crashing on my 32GB laptop.
Is this the way to go to remove unwanted alters for my egor object? Also, is there a more efficient way to do this? There are approximately 2000 ego networks in the data set.
I appreciate any help!