Skip to contents

This function imports ego-centered network data, stored in a single file, providing ego, alter and edge data. This data format is used by the Allbus 2010 (GESIS) and similar social surveys.

Usage

onefile_to_egor(
  egos,
  netsize = NULL,
  ID.vars = list(ego = "egoID"),
  attr.start.col,
  attr.end.col,
  max.alters,
  aa.first.var,
  aa.regex = NULL,
  var.wise = FALSE,
  ...
)

Arguments

egos

Data frame containing ego data (egos as cases)

netsize

Numeric, network size values are used to filter out empty alter entries. If the alter data is not structured in a way, where valid alters are stored before the invalid alters, pass NULL here and filter out invalid alters afterwards.

ID.vars

Character. For onefile_to_egor only the name of the ego ID needs to be provided.

attr.start.col

Index or name of the first column containing alter attributes.

attr.end.col

Index or name of the last column containing alter attributes.

max.alters

Maximum number of alters.

aa.first.var

First column containing alter-alter relations/ edges.

aa.regex

A Perl regular expression with name capture, intended to be run on column names and capturing via named capture the following regex groups: "attr", "src", and "tgt", representing the edge attribute being captured, the source (or the first alter identified), and the target (or the second alter identified) of the edge, respectively. See regex for more information.

var.wise

Logical value indicating if the alter attributes are sorted variable wise (defaults to FALSE).

...

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

References

Muller, C., Wellman, B., & Marin, A. (1999). How to Use SPSS to Study Ego-Centered Networks. Bulletin de Methodologie Sociologique, 64(1), 83-100.

Examples

path_to_one_file_8 <- system.file("extdata", "one_file_8.csv", package = "egor")
egos_8 <- read.csv2(path_to_one_file_8)

onefile_to_egor(
  egos = egos_8, netsize = egos_8$netsize,
  attr.start.col = "alter.sex.1",
  attr.end.col = "alter.age.8",
  aa.first.var = "X1.to.2",
  max.alters = 8)
#> Sorting data by egoID: 
#> Done.
#> Transforming alters data to long format: 
#> Done.
#> Transforming wide dyad data to edgelist: 
#> Done.
#> Note: Make sure to filter out alter-alter ties with invalid weight values.
#> Filtering out empty alter entries using provided network size values: 
#> Done.
#> # EGO data (active): 16 × 5
#>   .egoID sex   age      netsize egoID.1
#> * <chr>  <chr> <chr>      <int>   <int>
#> 1 1      w     66 - 100       8       1
#> 2 2      m     18 - 25        8       2
#> 3 3      w     26 - 35        8       3
#> 4 4      w     0 - 17         8       4
#> 5 5      m     36 - 45        8       5
#> # ℹ 11 more rows
#> # ALTER data: 128 × 4
#>   .altID .egoID alter.sex. alter.age.
#> * <chr>  <chr>  <chr>      <chr>     
#> 1 1      1      w          66 - 100  
#> 2 2      1      w          0 - 17    
#> 3 3      1      m          56 - 65   
#> # ℹ 125 more rows
#> # AATIE data: 448 × 4
#>   .egoID .srcID .tgtID weight
#> * <chr>  <chr>  <chr>   <int>
#> 1 1      1      2           2
#> 2 1      1      3           3
#> 3 1      1      4           1
#> # ℹ 445 more rows