These work like dplyr's bind_cols() and bind_rows(). The first argument has to be an egor object. Additional rows/columns are added bottom/RHS of the active data level (ego, alter, aatie).
Examples
e <- make_egor(12, 15)
# Adding a column to the ego level
additional_ego_columns <-
tibble(x = sample(1:3, 12, replace = TRUE))
append_cols(e, additional_ego_columns)
#> # EGO data (active): 12 × 7
#> .egoID sex age age.years country income x
#> * <dbl> <chr> <fct> <int> <chr> <dbl> <int>
#> 1 1 m 46 - 55 48 Australia 365 2
#> 2 2 w 36 - 45 38 Australia 36865 2
#> 3 3 m 0 - 17 10 Australia 33580 1
#> 4 4 m 18 - 25 22 Poland 29565 1
#> 5 5 w 18 - 25 17 Germany 71540 2
#> # ℹ 7 more rows
#> # ALTER data: 97 × 7
#> .altID .egoID sex age age.years country income
#> * <int> <dbl> <chr> <fct> <int> <chr> <dbl>
#> 1 1 1 m 46 - 55 49 Australia 50735
#> 2 2 1 m 46 - 55 47 USA 42340
#> 3 3 1 m 66 - 100 67 Poland 56210
#> # ℹ 94 more rows
#> # AATIE data: 193 × 4
#> .egoID .srcID .tgtID weight
#> * <int> <int> <int> <dbl>
#> 1 4 1 7 1
#> 2 1 2 7 1
#> 3 4 4 5 1
#> # ℹ 190 more rows
# Adding rows to the ego and alter level
additional_ego_rows <-
list(
.egoID = 13,
sex = "w",
age = factor("56 - 65"),
age.years = 60,
country = "Australia"
) %>%
as_tibble()
additional_alter_rows <-
list(
.altID = 1:5,
.egoID = rep(13, 5),
sex = sample(c("f", "m"), 5, replace = TRUE)
) %>%
as_tibble()
append_rows(e, additional_ego_rows) %>%
activate(alter) %>%
append_rows(additional_alter_rows)
#> # EGO data: 13 × 6
#> .egoID sex age age.years country income
#> * <dbl> <chr> <fct> <dbl> <chr> <dbl>
#> 1 1 m 46 - 55 48 Australia 365
#> 2 2 w 36 - 45 38 Australia 36865
#> 3 3 m 0 - 17 10 Australia 33580
#> # ℹ 10 more rows
#> # ALTER data (active): 102 × 7
#> .altID .egoID sex age age.years country income
#> * <int> <dbl> <chr> <fct> <int> <chr> <dbl>
#> 1 1 1 m 46 - 55 49 Australia 50735
#> 2 2 1 m 46 - 55 47 USA 42340
#> 3 3 1 m 66 - 100 67 Poland 56210
#> 4 4 1 w 46 - 55 54 Australia 49640
#> 5 5 1 m 36 - 45 44 Australia 50005
#> # ℹ 97 more rows
#> # AATIE data: 193 × 4
#> .egoID .srcID .tgtID weight
#> * <int> <int> <int> <dbl>
#> 1 4 1 7 1
#> 2 1 2 7 1
#> 3 4 4 5 1
#> # ℹ 190 more rows