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

twofiles_to_egor(
  egos,
  alters,
  ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target =
    "Target"),
  e.max.alters,
  e.first.var,
  selection = NULL,
  ...
)

Arguments

egos

Data frame containg ego data (egos as cases)

alters

Data frame containing alters data (alters as cases), alters are separated by a variable containg an egoID.

ID.vars

A named list containing column names of the relevant input columns:

ego

unique identifier associated with each ego, defaulting to "egoID"; has no effect if alters.df and aaties.df are both lists of data frames.

alter

unique-within-ego identifier associated with each alter, defaulting to "alterID"; optional aaties.df are not provided.

source

if aaties.df is provided, the column given the alter identifier of the origin of a relation.

target

if aaties.df is provided, the column given the alter identifier of the destination of a relation.

e.max.alters

Maximum number of alters that are included in edge data.

e.first.var

Index or name of the first column in egos containing edge data.

selection

Character naming numeric variable 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, row.names = 1) alters_8 <- read.csv2(path_to_alters_8.csv, row.names = 1) dy.first.var <- which(names(egos_8) == "X1.to.2") # convert to egor object twofiles_to_egor( egos = egos_8, alters = alters_8, e.max.alters = 8, e.first.var = dy.first.var)
#> Sorting data by egoID and alterID.
#> Transforming wide edge data to edgelist.
#> # EGO data (active): 128 x 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 -… 8 1 w 66 - 100 w #> 2 2 m 18 -… 8 2 w 36 - 45 m #> 3 3 w 26 -… 8 3 w 56 - 65 m #> # ALTER data: 1,024 x 4 #> .altID .egoID alter.sex alter.age #> <int> <int> <chr> <chr> #> 1 1 1 w 18 - 25 #> 2 2 1 w 46 - 55 #> 3 3 1 m 0 - 17 #> # AATIE data: 3,584 x 4 #> .egoID .srcID .tgtID weight #> <int> <dbl> <dbl> <int> #> 1 1 1 2 2 #> 2 1 1 3 3 #> 3 1 1 4 1