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).

append_rows(.egor, ..., .id = NULL)

append_cols(.egor, ...)

Arguments

.egor

An egor object.

...

Data frames to combine.

.id

Data frame identifier.

Value

egor object containing the additional rows/ columns on the active level.

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     36 - 45         45 Australia  41610     3
#> 2      2 m     66 - 100       100 Germany    19710     1
#> 3      3 m     0 - 17          10 Germany    54750     2
#> 4      4 w     66 - 100        68 Germany    46355     1
#> 5      5 w     66 - 100        89 Germany    53655     3
#> # … with 7 more rows
#> # ALTER data: 110 × 7
#>   .altID .egoID sex   age      age.years country income
#> *  <int>  <dbl> <chr> <fct>        <int> <chr>    <dbl>
#> 1      1      1 m     46 - 55         46 USA      50005
#> 2      2      1 w     66 - 100        71 Germany  69715
#> 3      3      1 m     66 - 100        66 Germany  49640
#> # … with 107 more rows
#> # AATIE data: 251 × 4
#>   .egoID .srcID .tgtID weight
#> *  <int>  <int>  <int>  <dbl>
#> 1      9      5      6  1    
#> 2      9     10     15  1    
#> 3      8      4      6  0.333
#> # … with 248 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     36 - 45         45 Australia  41610
#> 2      2 m     66 - 100       100 Germany    19710
#> 3      3 m     0 - 17          10 Germany    54750
#> # … with 10 more rows
#> # ALTER data (active): 115 × 7
#>   .altID .egoID sex   age      age.years country income
#> *  <int>  <dbl> <chr> <fct>        <int> <chr>    <dbl>
#> 1      1      1 m     46 - 55         46 USA      50005
#> 2      2      1 w     66 - 100        71 Germany  69715
#> 3      3      1 m     66 - 100        66 Germany  49640
#> 4      4      1 w     66 - 100        93 USA       4745
#> 5      5      1 m     26 - 35         30 Poland   10220
#> # … with 110 more rows
#> # AATIE data: 251 × 4
#>   .egoID .srcID .tgtID weight
#> *  <int>  <int>  <int>  <dbl>
#> 1      9      5      6  1    
#> 2      9     10     15  1    
#> 3      8      4      6  0.333
#> # … with 248 more rows