Skip to contents

These functions read ego-centered network data from the three files format, EgoWeb2.0 or openeddi and transform it to an egoR object. The three files format consists of an ego file, on alters file and one file containing the edge data. EgoWeb2.0 and openeddi use variations of this format.

Usage

threefiles_to_egor(
  egos,
  alters.df,
  edges,
  ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
  ego.vars = NULL,
  ...
)

read_egoweb(
  alter.file,
  edges.file,
  egos.file = NULL,
  ID.vars = list(ego = "EgoID", alter = "Alter.Number", source = "Alter.1.Number", target
    = "Alter.2.Number"),
  ego.vars = NULL,
  ...
)

read_openeddi(
  egos.file = NULL,
  alters.file = NULL,
  edges.file = NULL,
  ID.vars = list(ego = "puid", alter = "nameid", source = "nameid", target = "targetid"),
  ego.vars = NULL,
  ...
)

Arguments

egos

Data frame containing ego data (egos as cases)

alters.df

Data frame containing alters data (alters in rows), alters are connected to their ego by an egoID.

edges

Dataframe. A global edge list, first column is ego ID variable. egos.

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.

ego.vars

A data.frame of alter attributes in the wide format.

...

additional arguments to egor().

alter.file

A character specifiying the filename of the alters data.

edges.file

A character specifiying the filename of the edge data.

egos.file

A character specifiying the filename of the ego data.

alters.file

Character name of the alters data file.

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

Functions

  • read_egoweb(): This function reads in data from an EgoWeb 2.0 survey and transforms it to an egoR object. If no file name for the egos file is provided ego data is assumed to be merged with alters data and it will be extracted by read_egoweb. By default the standard ID variable names of EgoWeb are used, if you need to specify the ID variable names use the ID.vars parameter. Further Information: github.com/qualintitative/egoweb

  • read_openeddi(): This function reads in data created by the openeddi survey software and transforms it to an egoR object. If no parameters are provided read_openeddi will try to find the adequate files in the working directory. By default the standard ID variable names of openeddi are used, if you need to specify the ID variable names use the ID.vars parameter. Further Information: www.openeddi.com

Examples

# The data for read.egonet.threefiles() needs to be loaded with read.csv(), 
# for it to be converted to an egoR object.
egos.file <-  system.file("extdata", "egos_32.csv", package = "egor")
alters.file <- system.file("extdata", "alters_32.csv", package = "egor")
edges.file <-  system.file("extdata", "edges_32.csv", package = "egor")

egos <- read.csv2(egos.file)
alters <- read.csv2(alters.file)
edges <- read.csv2(edges.file)

tf <- threefiles_to_egor(egos = egos, alters.df = alters, edges = edges)

# read_egoweb() and read_openeddi() read the files directly from the disk.
# \donttest{
# Fetch current working directory
wd <- getwd()

setwd(system.file("extdata", "openeddi", package = "egor"))
oe <- read_openeddi()
#> No filenames specified, looking for ego, alters and edge files in working directory.

setwd(system.file("extdata", "egoweb", package = "egor"))
ew <- read_egoweb(alter.file = "alters_32.csv", edges.file = "edges_32.csv", 
                  egos.file = "egos_32.csv")
                  
# Restore working directory                   
setwd(wd)
# }