Closed mbojan closed 2 years ago
as.egor()
works for that, as longs as the object is of class nested_egor
.
library(egor)
a <- as_nested_egor(egor32)
a
#> # A tibble: 32 × 8
#> .egoID sex age age.years country income .aaties .alts
#> <dbl> <fct> <fct> <int> <chr> <dbl> <named list> <named li>
#> 1 1 m 56 - 65 63 Australia 29930 <tibble [32 × 4]> <tibble>
#> 2 2 m 26 - 35 33 Germany 17885 <tibble [33 × 4]> <tibble>
#> 3 3 m 66 - 100 74 Germany 20805 <tibble [33 × 4]> <tibble>
#> 4 4 w 18 - 25 21 Poland 29565 <tibble [27 × 4]> <tibble>
#> 5 5 m 0 - 17 9 Germany 15330 <tibble [37 × 4]> <tibble>
#> 6 6 m 0 - 17 6 Australia 23360 <tibble [30 × 4]> <tibble>
#> 7 7 m 66 - 100 84 Australia 19345 <tibble [43 × 4]> <tibble>
#> 8 8 w 66 - 100 100 Poland 35040 <tibble [32 × 4]> <tibble>
#> 9 9 m 36 - 45 38 USA 64605 <tibble [34 × 4]> <tibble>
#> 10 10 m 0 - 17 14 Australia 49275 <tibble [34 × 4]> <tibble>
#> # … with 22 more rows
#> Independent Sampling design (with replacement)
#> Called via srvyr
#> Data variables: .egoID (dbl), sex (fct), age (fct), age.years (int), country
#> (chr), income (dbl), .aaties (named list), .alts (named list)
as.egor(a)
#> # EGO data ([32mactive[39m): 32 × 6
#> .egoID sex age age.years country income
#> <dbl> <fct> <fct> <int> <chr> <dbl>
#> 1 1 m 56 - 65 63 Australia 29930
#> 2 2 m 26 - 35 33 Germany 17885
#> 3 3 m 66 - 100 74 Germany 20805
#> 4 4 w 18 - 25 21 Poland 29565
#> 5 5 m 0 - 17 9 Germany 15330
#> # ALTER data: 384 × 8
#> .altID .egoID egoID sex age age.years country income
#> <int> <dbl> <chr> <fct> <fct> <int> <chr> <dbl>
#> 1 1 1 1 m 46 - 55 48 USA 45625
#> 2 2 1 1 m 0 - 17 5 Germany 52925
#> 3 3 1 1 w 26 - 35 35 Australia 60225
#> # AATIE data: 1,056 × 4
#> .egoID .srcID .tgtID weight
#> <int> <int> <int> <dbl>
#> 1 1 3 6 1
#> 2 1 5 7 0.333
#> 3 1 4 7 1
Excellent! Thanks @tilltnet
I have some oldschool egor objects (with
.alts
and.aaties
columns etc.). Is/was there a routine around to update those to the current design? I'd hate to rework the pipeline I have... CC @tilltnet .