This function imports ego-centered network data, stored in two files, where one file contains the ego attributes and the edge information and the other file contains the alters data. This form of data storage for ego-centered network data is proposed by Muller, Wellman and Marin (1999).
Usage
twofiles_to_egor(
egos,
alters,
ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
max.alters,
aa.first.var,
selection = NULL,
...
)Arguments
- egos
Data framecontaining ego data (egos as cases)- alters
Data framecontaining alters data (alters in rows), alters are connected to their ego by anegoID.- ID.vars
A named list containing column names of the relevant input columns:
egounique identifier associated with each ego, defaulting to
"egoID"; has no effect ifalters.dfandaaties.dfare both lists of data frames.alterunique-within-ego identifier associated with each alter, defaulting to
"alterID"; optionalaaties.dfare not provided.sourceif
aaties.dfis provided, the column given the alter identifier of the origin of a relation.targetif
aaties.dfis provided, the column given the alter identifier of the destination of a relation.
- max.alters
Maximum number of alters that are included in edge data.
- aa.first.var
Index or name of the first column in
egoscontaining alter-alter data.- selection
Characternamingnumericvariable indicating alters selection with zeros and ones.- ...
additional arguments to
egor().
Value
An egor object is returned. It is a list of three data frames:
(1) ego: dataframe of all
egos and their attributes;
(2) alter: dataframe of all alters;
(3) aatie: dataframe of alter alter ties/ edges
Examples
path_to_alters_8.csv <- system.file("extdata", "alters_8.csv", package = "egor")
path_to_one_file_8 <- system.file("extdata", "one_file_8.csv", package = "egor")
# read data from disk
egos_8 <- read.csv2(path_to_one_file_8)
alters_8 <- read.csv2(path_to_alters_8.csv)
# convert to egor object
twofiles_to_egor(
egos = egos_8,
alters = alters_8,
max.alters = 8,
aa.first.var = "X1.to.2")
#> Sorting data by egoID and alterID.
#> Transforming wide edge data to edgelist.
#> Warning: Automatic coercion from logical to character was deprecated in purrr 1.0.0.
#> ℹ Please use an explicit call to `as.character()` within `map_chr()` instead.
#> ℹ The deprecated feature was likely used in the egor package.
#> Please report the issue at <https://github.com/tilltnet/egor/issues>.
#> # EGO data (active): 16 × 49
#> .egoID sex age netsize egoID.1 alter.sex.1 alter.age.1 alter.sex.2
#> * <int> <chr> <chr> <int> <int> <chr> <chr> <chr>
#> 1 1 w 66 - 100 8 1 w 66 - 100 w
#> 2 2 m 18 - 25 8 2 w 36 - 45 m
#> 3 3 w 26 - 35 8 3 w 56 - 65 m
#> 4 4 w 0 - 17 8 4 w 46 - 55 m
#> 5 5 m 36 - 45 8 5 w 18 - 25 w
#> # ℹ 11 more rows
#> # ℹ 41 more variables: alter.age.2 <chr>, alter.sex.3 <chr>, alter.age.3 <chr>,
#> # alter.sex.4 <chr>, alter.age.4 <chr>, alter.sex.5 <chr>, alter.age.5 <chr>,
#> # alter.sex.6 <chr>, alter.age.6 <chr>, alter.sex.7 <chr>, alter.age.7 <chr>,
#> # alter.sex.8 <chr>, alter.age.8 <chr>, X1.to.2 <int>, X1.to.3 <int>,
#> # X1.to.4 <int>, X1.to.5 <int>, X1.to.6 <int>, X1.to.7 <int>, X1.to.8 <int>,
#> # X2.to.3 <int>, X2.to.4 <int>, X2.to.5 <int>, X2.to.6 <int>, …
#> # ALTER data: 128 × 4
#> .altID .egoID alter.sex alter.age
#> * <dbl> <int> <chr> <chr>
#> 1 1 1 w 18 - 25
#> 2 2 1 w 46 - 55
#> 3 3 1 m 0 - 17
#> # ℹ 125 more rows
#> # AATIE data: 448 × 4
#> .egoID .srcID .tgtID weight
#> * <int> <dbl> <dbl> <int>
#> 1 1 1 2 2
#> 2 1 1 3 3
#> 3 1 1 4 1
#> # ℹ 445 more rows