Closed mbojan closed 4 years ago
See also "13.5.3 Methods" at http://adv-r.hadley.nz/s3.html#inheritance If we follow that path, I think we are in for quite some additional effort.
This issue is also related to #10
Not much we can do about it but hunker down and make it work, I think.
@tilltnet, thanks for implementing; three questions:
dplyr
verbs that subset or duplicate rows need to pass the update on to the ego.design
. For example [.egor
does that at https://github.com/tilltnet/egor/blob/2f0389e9a72ddf1b6348bed264dfadc55ecf3796/R/subset.egor.R#L194 ..alts
and .aaties
?[.egor
and subset.egor
, where we can manipulate the egos, the alters, or the alter-alter ties?@krivit
res <- filter(egor32, sex == "w", age == "18 - 25") # This will currently not subset the svydesign object correctly...
res <- filter(egor32, sex == "w" & age == "18 - 25") # ...while this will.
I guess there is some tidyeval function for that in the rlang package!? Any ideas?
For the other dplyr verbs the $variables object of the ego.design is updated. These changes seem to work so far.
In acc9487 I also deleted the summarise method, since it is not helpful to have an egor object as a result here.
@tilltnet , 3. can wait. 1. is a problem; a somewhat clunky solution is to add row indexes, filter the frame, get the remaining row indexes, and then use those to subset the survey.design
object.
Dang it! I referenced this issue in the wrong commit. Correct commit is: fcac6cacc7bbd2eff2e2c271e31ebe4bdf3788de
filter.egor now subsets the svydesign object correctly. It's done by adding a temporary index, as described by @krivit (Thanks!)
Still to do:
Maybe we could introduce an activate() function to allow for tidygraph-like operations, that would allow filtering/modifying the different data levels.
activate(egor, unit = c("ego", "alter", "aatie"))
dplyr
verbs would be applied to the activated unit/ data level.as_tibble.egor
could call as_alts_df
or as_aaties_df
, when one of these levels is activated.Caveats:
I like that direction @tilltnet , and actually mentioned that to @krivit off GitHub.
Currently
egor
objects extendtbl_df
which promises being able to take advantage of all the "dplyr" functionality cheaply. However, I just noticed that some of the "dplyr" functions drop the attributes. TrySo not an
egor
anymore and all the attributes are lost :(It seems to me that keeping "dplyr" compatibility would probably require implementing methods for all the "dyplr" verbs, e.g.
mutate.egor
and so on. This is unfortunate because I suspect that moving away from old "egonetR" implementation to "egor" was also to have the connection to "tidyverse" for a low development price.