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.
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, ... )
egos |
|
---|---|
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 inbalid 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 colum containing alter attributes. |
attr.end.col | Index or name of the last colum 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: |
var.wise | Logical value indicating if the alter attributes are sorted variable wise (defaults to FALSE). |
... | additional arguments to |
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
Muller, C., Wellman, B., & Marin, A. (1999). How to Use SPSS to Study Ego-Centered Networks. Bulletin de Methodologie Sociologique, 64(1), 83-100.
path_to_one_file_8 <- system.file("extdata", "one_file_8.csv", package = "egor") egos_8 <- read.csv2(path_to_one_file_8, row.names = 1) attr.start.col <- which(names(egos_8) == "alter.sex.1") attr.end.col <- which(names(egos_8) == "alter.age.8") dy.first.var <- which(names(egos_8) == "X1.to.2") onefile_to_egor( egos = egos_8, netsize = egos_8$netsize, attr.start.col = attr.start.col, attr.end.col = attr.end.col, aa.first.var = dy.first.var, max.alters = 8)#> Sorting data by egoID:#>#> Transforming alters data to long format:#>#> Transforming wide dyad data to edgelist:#>#>#> Filtering out empty alter entries using provided network size values:#>#> # EGO data (active): 128 x 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 #> # ALTER data: 1,024 x 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 #> # AATIE data: 3,584 x 4 #> .egoID .srcID .tgtID weight #> <chr> <chr> <chr> <int> #> 1 1 1 2 2 #> 2 1 1 3 3 #> 3 1 1 4 1