Type: | Package |
Title: | Import and Analyse Ego-Centered Network Data |
Version: | 1.24.2 |
Date: | 2024-02-01 |
Description: | Tools for importing, analyzing and visualizing ego-centered network data. Supports several data formats, including the export formats of 'EgoNet', 'EgoWeb 2.0' and 'openeddi'. An interactive (shiny) app for the intuitive visualization of ego-centered networks is provided. Also included are procedures for creating and visualizing Clustered Graphs (Lerner 2008 <doi:10.1109/PACIFICVIS.2008.4475458>). |
URL: | https://github.com/tilltnet/egor, https://egor.tillt.net/ |
BugReports: | https://github.com/tilltnet/egor/issues |
License: | AGPL-3 |
Depends: | R (≥ 3.5.0), dplyr, tibble |
Imports: | tidygraph, srvyr, tidyr, methods, utils, purrr, rlang, pillar |
Suggests: | knitr, testthat (≥ 2.1.0), rmarkdown, survey, shiny, igraph, network, haven |
VignetteBuilder: | knitr |
RoxygenNote: | 7.2.3 |
LazyData: | true |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2024-02-02 03:52:06 UTC; till |
Author: | Till Krenz [aut, cre],
Pavel N. Krivitsky [aut],
Raffaele Vacca [aut],
Michal Bojanowski |
Maintainer: | Till Krenz <egor@tillt.net> |
Repository: | CRAN |
Date/Publication: | 2024-02-02 05:30:02 UTC |
R Package for importing and analyzing ego-centered-network data
Description
Tools for importing, analyzing and visualizing ego-centered network data. Supports several data formats, including the export formats of 'EgoNet', 'EgoWeb 2.0' and 'openeddi'. An interactive (shiny) app for the intuitive visualization of ego-centered networks is provided. Also included are procedures for creating and visualizing Clustered Graphs (Lerner 2008 doi:10.1109/PACIFICVIS.2008.4475458).
Details
When analyzing ego-centered network data it is common to either
include or exclude data on ego. By default egor
excludes ego for most
analytic and visual functions and offers to include ego with the argument
include.ego
. In order for egor to automatically detect which ego-level
variables correspond to the alter-variables, the variables on the different
levels need to be named exactly the same. Alternatively the functions that
have an include.ego
argument have additional arguments that allow to
specify the name of the ego-level variable in question.
For further information see package webpage or GitHub.
Author(s)
Maintainer: Till Krenz egor@tillt.net
Authors:
Pavel N. Krivitsky pavel@statnet.org
Raffaele Vacca r.vacca@ufl.edu
Michal Bojanowski michal2992@gmail.com (ORCID)
Andreas Herz herzand@uni-hildesheim.de
Other contributors:
Markus Gamper m.gamper@uni-koeln.de [contributor]
Christopher McCarty ufchris@ufl.edu [contributor]
See Also
Useful links:
Report bugs at https://github.com/tilltnet/egor/issues
Calculate EI-Index of ego networks
Description
The EI-Index is the division of the surplus count intra-group edges over inter-group edges,
divided by total count of all edges.
This implementation uses the intra-group and inter-group density instead
of edge counts, when rescale
is set to TRUE
(default). The EI-Index is calculated for
the whole network and for subgroups. Alternatively, the EI index can be employed as a measurement
for egos tendency to homo-/heterophily - use comp_ei()
.
for that variant of the EI-Index.
Usage
EI(object, alt.attr, include.ego = FALSE, ego.attr = alt.attr, rescale = TRUE)
Arguments
object |
An |
alt.attr |
|
include.ego |
|
ego.attr |
|
rescale |
|
Details
The
whole network EI is a metric indicating the tendency of a network to be
clustered by the categories of a given factor variable (alt.attr
). The EI value of a
group describes the tendency of that group within a network to be connected
(if between 0 and 1) or not connected (if between -1 and 0)
to other groups. Differing group sizes can lead to a distortion of EI values
i.e. the ability of a big group A to form relationships to much smaller group B
is limited by the size of B. Even when all possible edges between A and B exist,
the EI value for group A might still be negative, classifying it as homophile.
The re-scaled
EI-Index values provided by this implementation substitutes absolute
edge counts by inter- and intra-group edge densities in order to avoid the
distortion of the EI-Index values. These values express the extend of homo- or heterophily
of the network and its subgroups, as made possible by subgroup sizes.
Value
Returns tibble
with the following columns:
ego ID (".egoID")
network EI-Index ("ei")
subgroup EI-Index values (named by value levels of
alt.attr
/ego.attr
)
References
Krackhardt, D., Stern, R.N., 1988. Informal networks and organizational crises: an experimental simulation. Social Psychology Quarterly 51 (2), 123-140.
Everett, M. G., & Borgatti, S. P. (2012). Categorical attribute based centrality: E-I and G-F centrality. Social Networks, 34(4), 562-569.
See Also
comp_ei()
, for an ego level homophily measure.
Examples
data("egor32")
EI(egor32, "sex")
32 sets of randomly created alter-alter ties belonging to ego-centered networks
Description
32 sets of randomly created alter-alter ties belonging to ego-centered networks
Usage
aaties32
Format
A data frame with 32 sets of alter-alter relations and 4 variables:
- .EGOID
ego identifier
- .SRCID
source alter ID
- .TGTID
target alter ID
- weight
weight of relation
Activate ego, alter or alter-alter tie data level of an egor dataset
Description
This function activates one of the data levels of an egor dataset, so that the dplyr verbs know which level to execute on.
Usage
## S3 method for class 'egor'
activate(.data, what)
Arguments
.data |
The |
what |
|
Examples
e <- make_egor(5,50)
e %>%
activate("aatie") %>%
mutate(weight2 = 2 + weight) %>%
activate("alter") %>%
mutate(age.years = age.years^3)
Simulated Allbus 2010 Data
Description
A dataset simulated based on the the original Allbus 2010 SPSS data. The dataset simulates 100 respondents and does not resemble any actual Allbus respondents. Each variable is randomly generated based on the range of the original variables, co-variations between variables are disregarded. The data’s purpose is purely to demonstrate how to technically work with the Allbus data using egor and R - no analytical assumptions should be made based on this data!
Usage
allbus_2010_simulated
Format
A tibble/ data.frame of 100 simulated respondents/ rows and 981
variables/ columns. Each variable is a labelled dbl
.
Details
The dataset contains (simulated!) answers to two ego-centered name generators.
Set and query the alter nomination design
Description
Extract, set, or update the alter nomination design associated with an ego-centered dataset.
Usage
alter_design(x, ...)
## S3 method for class 'egor'
alter_design(x, which, ...)
alter_design(x, ...) <- value
## S3 replacement method for class 'egor'
alter_design(x, which, ...) <- value
Arguments
x |
an |
... |
arguments to be passed to methods |
which |
name of the alter design setting to query or replace |
value |
if |
32 sets of randomly created alters belonging to ego-centered networks
Description
32 sets of randomly created alters belonging to ego-centered networks
Usage
alters32
Format
A data frame with 32 sets of up to 32 alters per egoID and 7 variables:
- .ALTID
alter identifier
- .EGOID
ego identifier
- age
age in categories
- age.years
age in years
- country
country
- income
income
- sex
gender
Calculate diversity measures on an egor
object.
Description
alts_diversity_count()
counts the categories of a variable present in the
networks of an egor
object. alts_diversity_entropy()
calculates the Shannon
entropy as a measurement for diversity of an alter attribute.
Usage
alts_diversity_count(object, alt.attr)
alts_diversity_entropy(object, alt.attr, base = 2)
Arguments
object |
An |
alt.attr |
A |
base |
|
Value
A tibble
with the ego ID and a numeric
result vector.
Author(s)
Michał Bojanowski, michal2992@gmail.com
Till Krenz, egor@tillt.net
Examples
data("egor32")
alts_diversity_count(egor32, "age")
alts_diversity_entropy(egor32, "age")
Append rows/columns to ego, alter or aatie data
Description
These work like dplyr's bind_cols() and bind_rows(). The first argument has to be an egor object. Additional rows/columns are added bottom/RHS of the active data level (ego, alter, aatie).
Usage
append_rows(.egor, ..., .id = NULL)
append_cols(.egor, ...)
Arguments
.egor |
An |
... |
Data frames to combine. |
.id |
Data frame identifier. |
Value
egor
object containing the additional rows/ columns on the active level.
Examples
e <- make_egor(12, 15)
# Adding a column to the ego level
additional_ego_columns <-
tibble(x = sample(1:3, 12, replace = TRUE))
append_cols(e, additional_ego_columns)
# Adding rows to the ego and alter level
additional_ego_rows <-
list(
.egoID = 13,
sex = "w",
age = factor("56 - 65"),
age.years = 60,
country = "Australia"
) %>%
as_tibble()
additional_alter_rows <-
list(
.altID = 1:5,
.egoID = rep(13, 5),
sex = sample(c("f", "m"), 5, replace = TRUE)
) %>%
as_tibble()
append_rows(e, additional_ego_rows) %>%
activate(alter) %>%
append_rows(additional_alter_rows)
egor - a data class for ego-centered network data.
Description
The function egor()
is used to create an egor object from
ego-centered network data. as.egor()
converts a list of igraph
/network
objects or
a nested_egor
objects to an egor
object.
Usage
as.egor(x, ...)
## S3 method for class 'nested_egor'
as.egor(
x,
ID.vars = list(ego = ".egoID", alter = ".alterID", source = ".Source", target =
".Target"),
...
)
## S3 method for class 'list'
as.egor(x, ego_name = NULL, ...)
egor(
alters,
egos = NULL,
aaties = NULL,
ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
ego_design = NULL,
alter_design = list(max = Inf)
)
Arguments
x |
|
... |
arguments to be passed to methods |
ID.vars |
A named list containing column names of the relevant input columns:
|
ego_name |
|
alters |
either a |
egos |
|
aaties |
|
ego_design |
A |
alter_design |
A
|
Details
If parameters alters.df
, egos.df
, and aaties.df
are
data frames, they need to share a common ego ID variable, with
corresponding values. If alters.df
and aaties.df
are lists of
data frames, egoID
is ignored and they are matched by position
with the rows of egos.df
. Of the three parameters only
alters.df
is necessary to create an egor
object, and
egos.df
and aaties.df
are optional.
Value
Returns an egor
object, which is a named list
with three
tibble data.frames
: ego, alter and aatie (alter-alter ties).
Each data set has an .egoID
column, that groups the data belonging to one
ego. Additionally the alter data has an .alterID
column, that links to
the columns .srcID
and .tgtID
in the alter-alter tie data.
In addition, egor
has two attributes: ego_design
, containing an
object returned by srvyr::as_survey_design()
specifying the sampling
design by which the egos were selected and alter_design
, a
list
containing specification of how the alters were
nominated. See the argument above for currently implemented
settings.
Functions
-
as.egor(nested_egor)
: Can convert (legacy)nested_egor
object toegor
object.
Note
Column names .alts
, .aaties
, and .egoRow
are reserved
for internal use of egor
and should not be used to store
persistent data. Other .
-led column names may be reserved in
the future.
See Also
as_tibble()
for extracting ego, alter, and alter–alter tables, as tibble
s or as srvyr
's tbl_svy
surveys.
Examples
data("egos32")
data("alters32")
data("aaties32")
egor(alters32,
egos32,
aaties32,
ID.vars = list(ego = ".EGOID",
alter = ".ALTID",
source = ".SRCID",
target = ".TGTID"))
Convert egor
object to network
or igraph
objects
Description
These functions convert an egor
object into a list of network
or igraph
objects.
By default ego itself is not included in the created objects, there is
a parameter (include.egor) that allows for including ego.
Usage
as_igraph(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
## S3 method for class 'nested_egor'
as_igraph(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
## S3 method for class 'egor'
as.igraph(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
as_network(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
## S3 method for class 'egor'
as.network(
x,
directed = FALSE,
include.ego = FALSE,
ego.attrs = NULL,
ego.alter.weights = NULL,
graph.attrs = ".egoID"
)
Arguments
x |
An |
directed |
Logical, indicating if alter-alter relations are directed. |
include.ego |
|
ego.attrs |
Vector of names (character) or indices (numeric) of ego
variables that should be carried over to the network/
igraph objects. This is ignored, when |
ego.alter.weights |
Vector of names (character) or indices (numeric) of alter variables that should be carried over to the the network/ igraph objects, as edge attributes of the ego-alter relations. This is ignored, when 'include.ego = FALSE“ (default). |
graph.attrs |
Vector of names (character) or indices (numeric) of
ego variables that are supposed to be carried over to the igraph object
as graph attributes or the network object as network attributes. By
default |
Details
The names of the variables specified in ego.attr and ego.alter.attr need to be the same as the names of corresponding alter attributes, in order for those variables to be merged successfully in the resulting network/ igraph object (see example).
Examples
e <- make_egor(3, 22)
as_igraph(e)
Extract ego, alter, and alter-alter tables from an egor
object.
Description
Provided an egor
object, these functions create a "global" tibble
or srvyr
's tbl_svy
object
containing egos, alter attributes, or alter-alter relations. The resulting tables
are useful for advanced analysis procedures, e.g. multi-level regressions.
as_tibble()
method for egor
extracts the currently active component (ego
, alter
, or aaties
) table, optionally joining it with the others, dropping any survey design information.
as_survey()
method for egor
instead returns a srvyr
tbl_svy
survey, taking into account any replication due to multiple alters or alter-alter ties incident on each ego. If no design is specified for the egos, then the default design (simple random sample with replacement) is assumed as the starting point.
as_egos_df()
, as_alters_df()
, as_aaties_df()
, as_egos_survey()
, as_alters_survey()
, and as_aaties_survey()
are convenience functions for the as_tibble()
and as_survey()
methods, activating the corresponding component of the egor
object.
Usage
## S3 method for class 'egor'
as_tibble(x, ..., include.ego.vars = FALSE, include.alter.vars = FALSE)
## S3 method for class 'egor'
as_survey(.data, ..., include.ego.vars = FALSE, include.alter.vars = FALSE)
as_egos_df(object)
as_alters_df(object, include.ego.vars = FALSE)
as_aaties_df(object, include.ego.vars = FALSE, include.alter.vars = FALSE)
as_egos_survey(object, include.ego.vars = FALSE)
as_alters_survey(object, include.ego.vars = FALSE)
as_aaties_survey(object, include.ego.vars = FALSE, include.alter.vars = FALSE)
Arguments
x , object , .data |
An |
... |
Additional arguments, currently unused. |
include.ego.vars |
Logical, specifying if ego variables should be included in the result. |
include.alter.vars |
Logical, specifying if alter variables should be included in the result. |
Value
A tibble
for the as_tibble
and *_df
functions and a tbl_svy
for as_survey
and the *_survey
functions.
Examples
# Load example data
data(egor32)
as_tibble(egor32) # Ego table.
egor32 %>%
activate("alter") %>%
as_tibble(include.ego.vars=TRUE) # Alter table, but also with ego variables.
library(srvyr)
as_survey(egor32) # Ego table with survey design.
# Despite alter table being active, obtain the ego table.
(egor32 <- activate(egor32, "alter"))
as_egos_df(egor32)
# Create global alter table
as_alters_df(egor32)
# Create global alter-alter relations table
as_aaties_df(egor32)
# ... adding alter variables
as_aaties_df(egor32, include.alter.vars = TRUE)
as_egos_survey(egor32)
as_alters_survey(egor32) # Notice the resulting cluster design.
Cluster ego-centered networks by a grouping factor
Description
The idea of clustered graphs is to reduce the complexity of an ego-centered network
graph by visualizing alters in clusters defined by a categorical variable (Lerner et al. 2008).
clustered_graphs()
calculates group sizes, inter and intra group tie
densities and returns these informations in a list
of igraph
objects.
Usage
clustered_graphs(object, ..., clust.groups)
## S3 method for class 'list'
clustered_graphs(object, aaties, clust.groups, ...)
## S3 method for class 'egor'
clustered_graphs(object, clust.groups, ...)
## S3 method for class 'data.frame'
clustered_graphs(object, aaties, clust.groups, egoID = ".egoID", ...)
Arguments
object |
An |
... |
arguments to be passed to methods |
clust.groups |
A |
aaties |
|
egoID |
|
Value
clustered_graphs
returns a list of graph objects representing
the clustered ego-centered network data;
References
Brandes, U., Lerner, J., Lubbers, M. J., McCarty, C., & Molina, J. L. (2008). Visual Statistics for Collections of Clustered Graphs. 2008 IEEE Pacific Visualization Symposium, 47-54.
See Also
vis_clustered_graphs
for visualizing clustered graphs
Examples
data("egor32")
# Simplify networks to clustered graphs, stored as igraph objects
graphs <- clustered_graphs(egor32, "country")
# Visualise
par(mfrow = c(2,3))
vis_clustered_graphs(
graphs[1:5]
)
par(mfrow = c(1,1))
Obtain the index of a column in a data frame (or a list), producing an error if there is a problem.
Description
Obtain the index of a column in a data frame (or a list), producing an error if there is a problem.
Usage
col_idx(name, df)
Arguments
name |
a character vector giving the names of the columns to look up. |
df |
a |
Value
An integer giving the column index of the named column.
Note
Numeric inputs for name
are passed through, so this
function is safe to use if the input is already a column index.
Longest common prefix of a set of strings.
Description
Longest common prefix of a set of strings.
Usage
common_prefix(x)
Arguments
x |
a character vector. |
Value
A character vector that is the longest common substring at the start of each of the input vectors.
Calculate the EI-Indices of an egor
object as a measurement of ego-alter homophily
Description
comp_ei()
calculates the EI-Index values as a measurement for ego-alter homo-/heterophily.
Usage
comp_ei(object, alt.attr, ego.attr)
Arguments
object |
An |
alt.attr |
A |
ego.attr |
A |
Value
A tibble
with the ego ID and a numeric
result vector.
Examples
data("egor32")
comp_ei(egor32, "age", "age")
Calculate custom compositional measures on an egor
object
Description
comp_ply()
applies a function, that uses an alter attribute to calculate
a compositional measurement, on all networks in an egor
object and returns a
numeric vector
.
Usage
comp_ply(object, alt.attr, .f, ..., ego.attr = NULL, result.name = "result")
Arguments
object |
An |
alt.attr |
A |
.f |
A |
... |
Optional arguments to |
ego.attr |
Optional |
result.name |
Optional |
Details
When an ego attribute is used the .f
is called like this:
.f(alt.attr, ego.attr, ...)
. .f
must return a single numeric value.
Value
A tibble
with the ego ID and a numeric
result vector.
Author(s)
Michał Bojanowski, michal2992@gmail.com
Till Krenz, egor@tillt.net
Examples
df <- make_egor(10, 32)
comp_ply(df, "age.years", sd, na.rm = TRUE)
Calculate the composition of alter attributes in an egor
object
Description
composition()
calculates the proportional or absolute composition of
alters for a given attribute/variable.
Usage
composition(object, alt.attr, absolute = FALSE)
Arguments
object |
An |
alt.attr |
A |
absolute |
|
Value
A tibble
with the ego ID and values per category of alt.attr
as numeric
columns.
Examples
data("egor32")
composition(egor32, "sex")
Count attribute combinations of dyads in ego-centered networks
Description
count_dyads()
counts the attribute combinations of alter-alter ties/ dyads
in ego-centered networks. The results can be returned as a wide or long
tibble
/ data.frame
.
Usage
count_dyads(
object,
alter_var_name,
return_as = c("wide", "long"),
prefix = NULL
)
Arguments
object |
An |
alter_var_name |
|
return_as |
|
prefix |
|
Value
Wide or long tibble
/ data.frame
.
Examples
data(egor32)
count_dyads(object = egor32,
alter_var_name = "country")
# Return result as long tibble.
count_dyads(object = egor32,
alter_var_name = "country",
return_as = "long")
Transforms edge lists to alter-alter wide format data.
Description
Transforms edge lists to alter-alter wide format data.
Usage
edgelist_to_wide(edges, src_tgt_id = c(".SRCID", ".TGTID"), weight = "weight")
Arguments
edges |
List of |
Calculate Burt constraint for the egos of ego-centered networks
Description
This calculates Burt's network constraint for all egos in an egor object. It iterates over each network and applies igraph::constraint. A weight variable can be specified.
Usage
ego_constraint(object, weights = NULL, ego.alter.weights = weights)
Arguments
object |
An |
weights |
|
ego.alter.weights |
|
Details
The calculation of weighted network constraint only works, if the alter-alter tie weights are complemented by a alter level variable specifying the same weight for the ego-alter ties.
Value
Numeric
vector with a constraint value for each ego.
References
Burt, R. (2004). Structural holes and good ideas. American Journal of Sociology, (110), 349–399.
Examples
data(egor32)
ego_constraint(egor32)
Calculate the relationship density in ego-centered networks
Description
This function uses an egor
object and calculates the density of all
the ego-centered networks listed in the 'egor' object. Instead of an
egor
object, alter and alter-alter data can be provided as lists
or data.frames
.
Usage
ego_density(object, ...)
## S3 method for class 'egor'
ego_density(object, weight = NULL, max.netsize = NULL, directed = FALSE, ...)
Arguments
object |
An |
... |
arguments to be passed to methods |
weight |
|
max.netsize |
Optional parameter. Constant value used if the number of alters whose relations were collected is limited. |
directed |
logical indicating if the alter-alter relation data/ edges are directed or un-directed. |
Value
returns a vector
of network density values.
Examples
data("egor32")
ego_density(egor32)
Set and query the ego sampling design
Description
Extract, set, remove, or update the survey design associated with an ego-centered dataset.
Usage
ego_design(x, ...)
## S3 method for class 'egor'
ego_design(x, ...)
## S3 method for class 'nested_egor'
ego_design(x, ...)
ego_design(x, ...) <- value
## S3 replacement method for class 'egor'
ego_design(x, ...) <- value
## S3 replacement method for class 'nested_egor'
ego_design(x, ...) <- value
has_ego_design(x)
## S3 method for class 'egor'
has_ego_design(x)
## S3 method for class 'nested_egor'
has_ego_design(x)
strip_ego_design(x)
Arguments
x |
an |
... |
arguments to be passed to methods |
value |
a |
Note
This can be useful for adjusting or re-initializing the ego design information after the underlying ego attributes had been modified.
32 randomly created ego-centered networks stored as an egor object
Description
32 randomly created ego-centered networks stored as an egor object
Usage
egor32
Format
An egor object with 32 ego-centered networks (5 variables):
- egoID
ego identifier
- sex
ego's gender
- age
ego's age
- .alts
nested column/list containing alters
- .aaties
nested column/list containing alter-alter relations
Display names and values of global egor options.
Description
Display names and values of global egor options.
Usage
egor_options()
Details
Currently egor makes use of the following global options. Use
options()
to change values.
egor.print.rows.active.level
-
Numeric
. Amount of rows to display when printing the active level of anegor
object.
egor.print.rows.inactive.level
-
Numeric
. Amount of rows to display when printing the inactive levels of anegor
object.
egor.print.switch.active.level.to.top
-
Logical
. When printing an egor object, should the active data-level always be printed first?
egor.return.results.with.design
-
Logical
.egor
functions that return ego-level results (e.g. one value per ego) return asvy_tbl
object containing theego_design()
, when this is set toTRUE
.
egor
Network Visualization App
Description
Launches an interactive Shiny Web App that creates a list of
igraph
objects from an 'egor' object and offers the user several graphical
means of interacting with the visualization parameters for all networks in
the egor
object.
Usage
egor_vis_app(object = NULL, shiny_opts = list(launch.browser = TRUE))
Arguments
object |
An |
shiny_opts |
A |
Note
This function requires shiny
to be installed.
Examples
#if(interactive()){
# data("egor32")
# egor_vis_app(egor32)
#}
32 randomly created egos belonging to ego-centered networks
Description
32 randomly created egos belonging to ego-centered networks
Usage
egos32
Format
A data frame with 32 sets of alter-alter relations and 4 variables:
- .EGOID
ego identifier
- age
age in categories
- age.years
age in years
- country
country
- income
income
- sex
gender
This extracts egos from igraph/network data if they are named in ego_name
and returns an egor object
Description
This extracts egos from igraph/network data if they are named in ego_name
and returns an egor object
Usage
extract_egos_and_return(graph_attrs, alters, edges, ego_name = NULL)
Arguments
graph_attrs |
List of graph attributes |
alters |
alters |
edges |
edges |
ego_name |
ego_name |
A selective subset of GSS 2004 data
Description
This is a selective subset of General Social Survey 2004 data containing variables from network questions. See Details for description how this particular subset was selected. The data has a near 0 research value, it is provided to illustrate the functions in egor package.
Usage
gss2004
Format
A tibble with 499 rows and the variables listed below. Data was imported from SPSS file and are labelled. Functions in the labelled package can be used to handle them.
Variables:
- id
Case ID
- vpsu, vstrat, wtssall
Design variables and weight
- age
Ego's age in years
- race
Ego's race. 1=white, 2=black, 3=other
- sex
Ego's sex. 1=male, 2=female
- marital
Ego's marital status. 1=married, 2=widowed, 3=divorced, 4=separated, 5=never married
- numgiven
Number of alters mentioned
- age[1-5]
Alter's age in years
- race[1-5]
Alter's race. 1=asian, 2=black, 3=hispanic, 4=white, 5=other
- sex[1-5]
Alter's sex. 1=male, 2=female
- spouse[1-5]
Whether alter is a spouse of ego. 1=mentioned, 2=not mentioned
- close[1-4][2-5]
How close are the two alters according to ego. 1=especially close, 2=know each other, 3=total strangers
Details
This dataset was created from original GSS 2004 data for illustrative
purposes such that (1) it is small and (2) contains just enough variation in
respondent's personal networks to illustrate various functions in the
package. It is essentially a stratified sample from original data (1472
cases). Strata correspond to groups of cases created from unique combinations
of values on the following ego variables: age
(3 categories), race
,
sex
, marital
, numgiven
. At most 2 cases were sampled from each stratum
via simple random sampling with replacement.
Source
General Social Survey data at NORC: https://gss.norc.org/get-the-data
General helper functions
Description
Helper functions for ego centered network analysis
Usage
as_nested_egor(x)
alters_by_ego(x)
## S3 method for class 'egor'
alters_by_ego(x)
## S3 method for class 'nested_egor'
alters_by_ego(x)
aaties_by_ego(x)
## S3 method for class 'egor'
aaties_by_ego(x)
## S3 method for class 'nested_egor'
aaties_by_ego(x)
dyad.poss(max.alters, directed = FALSE)
sanitize.wide.edges(max.alters)
create_edge_names_wide(x)
dyads_possible_between_groups(x, y, geometric = TRUE)
din_page_dist(x)
Arguments
x |
|
max.alters |
A |
directed |
A |
y |
|
geometric |
|
Functions
-
as_nested_egor()
: Converts an egor object to a "legacy" egor object with nested .alts and .aaties columns. -
alters_by_ego()
: Splits the alter table into a list of tables (possibly 0-row) of alters associated with each ego, in the same order as the ego table. -
aaties_by_ego()
: Splits the alter–alter ties table into a list of tables (possibly 0-row) of alter–alter associated with each ego, in the same order as the ego table. -
dyad.poss()
: Returns the count of possible edges in an un-directed or directed, ego-centered network, based on the number of alters. -
sanitize.wide.edges()
: Generates adata.frame
marking possible dyads in a wide alter-alter relationdata.frame
. Row names corresponds to the network size. This is useful for sanitizing alter-alter relations in the wide format. -
create_edge_names_wide()
: Creates avector
of names for variables containing data on alter-alter relations/ dyads in ego-centered networks. -
dyads_possible_between_groups()
: Calculates the possible edges between members of different groups in an ego-centered network. -
din_page_dist()
: Calculates the optimal distribution of a number of equally sized objects on a DIN-Norm DIN 476 (i.e. DIN A4) page in landscape view.
Create layout for an egogram
Description
This creates pairs of x and y coordinates for a egogram, accompanied by alter IDs for each coordinate pair.
Usage
layout_egogram(altID, venn_var, pie_var)
Arguments
altID |
Vector of alter IDs. |
venn_var |
Vector of values representing alter groups corresponding with venns in an egogram. |
pie_var |
Vector of values representing alter groups corresponding with pieces of pie in an egogram. |
Value
A dataframe with three columns: x, y and altID.
Generate a random edge list for one network.
Description
Generate a random edge list for one network.
Usage
make_edge_list(netsize)
Arguments
netsize |
|
Generate random ego-centered-network data.
Description
This function generates random ego-centered-network data for a specified number of networks with a maximum network size. The network size of the generated networks is a normal distribution with sd=5.
Usage
make_egor(net.count, max.alters, netsize_fixed = FALSE, plot = FALSE)
Arguments
net.count |
Number of networks/ egos to generate. |
max.alters |
Maximum size of networks. |
netsize_fixed |
|
plot |
whether to plot the network size distribution. |
Import ego-centered network data from 'one file format'
Description
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 |
|
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: |
var.wise |
Logical value indicating if the alter attributes are sorted variable wise (defaults to FALSE). |
... |
additional arguments to |
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)
Order edge list columns with source and target at the beginning.
Description
Order edge list columns with source and target at the beginning.
Usage
order.edge.list.columns(edges, source_, target)
Plotting egor objects
Description
egor objects can be plotted as egographs or egograms. By default networks of the four first egos are plotted.
Usage
plot_egograms(
x,
ego_no = 1,
x_dim = 1,
y_dim = 1,
venn_var = NULL,
pie_var = NULL,
ascending_inwards = TRUE,
vertex_size_var = NULL,
vertex_color_var = NULL,
vertex_color_palette = "Heat Colors",
vertex_color_legend_label = vertex_color_var,
vertex_label_var = "name",
edge_width_var = NULL,
edge_color_var = NULL,
edge_color_palette = "Heat Colors",
highlight_box_col_var = NULL,
highlight_box_col_palette = "Heat Colors",
res_disp_vars = NULL,
vertex_zoom = 1,
edge_zoom = 2,
font_size = 1,
pie_colors = NULL,
venn_gradient_reverse = FALSE,
show_venn_labels = TRUE,
include_ego = FALSE,
...
)
plot_ego_graphs(
x,
ego_no = 1,
x_dim = 1,
y_dim = 1,
vertex_size_var = NULL,
vertex_color_var = NULL,
vertex_color_palette = "Heat Colors",
vertex_color_legend_label = vertex_color_var,
vertex_label_var = "name",
edge_width_var = NULL,
ego_alter_edge_width_var = if (!is.null(edge_width_var) & include_ego) edge_width_var,
edge_color_var = NULL,
ego_alter_edge_color_var = if (!is.null(edge_color_var) & include_ego) edge_color_var,
edge_color_palette = "Heat Colors",
highlight_box_col_var = NULL,
highlight_box_col_palette = "Heat Colors",
res_disp_vars = NULL,
vertex_zoom = 1,
edge_zoom = 3,
font_size = 1,
include_ego = FALSE,
...
)
plot_egor(
x,
ego_no = 1,
x_dim = 2,
y_dim = 2,
...,
type = c("egograph", "egogram")
)
## S3 method for class 'egor'
plot(x, ...)
Arguments
x |
An egor object. |
ego_no |
Ego row number. |
x_dim |
Number of ego networks to plot horizontally. |
y_dim |
Number of ego networks to plot vertically |
venn_var |
Name (character) of alter column. |
pie_var |
Name (character) of alter column. |
ascending_inwards |
|
vertex_size_var |
Name ( |
vertex_color_var |
Name ( |
vertex_color_palette |
Name ( |
vertex_color_legend_label |
Character. |
vertex_label_var |
Name ( |
edge_width_var |
Name ( |
edge_color_var |
Name ( |
edge_color_palette |
Name ( |
highlight_box_col_var |
Name ( |
highlight_box_col_palette |
Name ( |
res_disp_vars |
Name ( |
vertex_zoom |
Numeric. |
edge_zoom |
Numeric. |
font_size |
Numeric. |
pie_colors |
|
venn_gradient_reverse |
|
show_venn_labels |
Logical. |
include_ego |
Logical. |
... |
Additional arguments forwarded to plot.igraph. |
ego_alter_edge_width_var |
Name ( |
ego_alter_edge_color_var |
Name ( |
type |
Character. Either "egograph" or "egogram". |
Details
For type equals "egograph" ego networks are plotted with igraph
's
plotting engine. "egogram" uses a special layout that places the nodes
on a map of (1) concentric circles with (2) subsections, that can be mapped to
alter variables.
Available color palettes are:
Heat Colors
Yellow-Green
Red-Yellow
Blue-Red
Black-White
Greys
Rainbow
Topo Colors
Functions
-
plot_egograms()
: Plots an ego-socio-gram. -
plot_ego_graphs()
: Plots an ego graph.
Examples
e <- make_egor(net.count = 5, max.alters = 12)
plot_egograms(x = e,
ego_no = 2,
venn_var = "sex",
pie_var = "country",
vertex_size_var = "age")
plot(e)
Read ego-centered network data exported with EgoNet software as an egor
object
Description
This function imports ego-centered network data from folders with separate files for alters-level and edge data. It will run some basic checks upon the completeness of the data and inform the user of potential problems. This function can be used to import data exported from EgoNet (McCarty 2011).
Usage
read_egonet(
egos.file,
alter.folder,
edge.folder,
csv.sep = ",",
ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
first.col.row.names = FALSE,
...
)
Arguments
egos.file |
File name of the .csv file containing the ego data. |
alter.folder |
Folder name of the folder containing the alter data in separate .csv files for each ego/ network. |
edge.folder |
Folder name of the folder containing the edge/ tie data in separate .csv files for each ego/ network. |
csv.sep |
|
ID.vars |
A named list containing column names of the relevant input columns:
|
first.col.row.names |
|
... |
additional arguments to |
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
egos.file <- system.file("extdata", "egos_32.csv", package = "egor")
alters.folder <- system.file("extdata", "alters_32", package = "egor")
edge.folder <- system.file("extdata", "edges_32", package = "egor")
ef <- read_egonet(egos.file = egos.file,
alter.folder = alters.folder,
edge.folder = edge.folder,
csv.sep = ";")
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- tidygraph
Returns results inheriting srvyr
design if the input egor object has a an
ego_design
and global option "egor.return.results.with.design" is TRUE
or
'NULL'.
Description
Returns results inheriting srvyr
design if the input egor object has a an
ego_design
and global option "egor.return.results.with.design" is TRUE
or
'NULL'.
Usage
return_results(x, results)
Arguments
x |
Original |
results |
|
Rotate circle or star graph layout so that it 'stands' on two bottom nodes.
Description
Rotate circle or star graph layout so that it 'stands' on two bottom nodes.
Usage
rotate_to_equilibrium(xy_mat)
Arguments
xy_mat |
A two column matrix with x and y coordinates containing the graph layout. |
Rotate a matrix of x and y coordinates by a radian
Description
Rotate a matrix of x and y coordinates by a radian
Usage
rotate_xy(xy_mat, rad, direction = 1)
Arguments
xy_mat |
A two column matrix with x and y coordinates. |
rad |
|
direction |
|
Convert a table to a list of rows
Description
A convenience function converting a data.frame()
or a tibble()
.
Usage
rowlist(x)
Arguments
x |
a |
Value
A list()
of length nrow(x)
, with each element itself a
named list()
containing the elements in the corresponding
row.
Examples
library(tibble)
(df <- tibble(x=2:1, y=list(list(1:3), list(3:4))))
rowlist(df)
Filter and Subset Ego-centered Datasets
Description
Functions to index and take subsets of egor()
objects: manipulate
egos, alters, or alter-alter ties.
Usage
## S3 method for class 'egor'
subset(x, subset, ..., unit = attr(x, "active"))
## S3 method for class 'egor'
x[i, j, unit = attr(x, "active"), ...]
Arguments
x |
an |
subset |
either an expression evaluated on each of the rows of
the selected unit (as in the eponymous argument of
|
... |
extra arguments to |
unit |
a selector of the unit of analysis being affected: the
egos, the alters or the (alter-alter) ties. Note that only one
type of unit can be affected at a time. Defaults to the current
active unit selected by |
i |
numeric or logical vector indexing the appropriate unit. |
j |
either an integer vector specifying which columns of the
filtered structure (ego, alters, or ties) to select, or a logical
vector specifying which columns to keep. Note that the special
columns .egoID, .altID, .srcID, .tgtID are not indexed by |
Details
Removing or duplicating an ego will also remove or duplicate their alters and ties.
Value
An egor()
object.
Examples
# Generate a small sample dataset
(e <- make_egor(5,4))
# First three egos in the dataset
e[1:3,]
# Using an external vector
# (though normally, we would use e[.keep,] here)
.keep <- rep(c(TRUE, FALSE), length.out=nrow(e$ego))
subset(e, .keep)
# Filter egos
subset(x = egor32, subset = egor32$ego$variables$sex == "m", unit="ego")
subset(x = egor32, sex == "m")
# Filter alters
subset(x = egor32, sex == "m", unit = "alter")
# Filter aaties
subset(x = egor32, weight != 0, unit = "aatie")
# Filter egos by alter variables (keep only egos that have more than 13 alters)
subset(x = egor32, nrow(alter) > 13, unit = "alter")
# Filter alters by ego variables (keep only alters that have egos from Poland)
subset(x = egor32, ego$country == "Poland", unit = "ego")
# Filter edges by alter variables (keep only edges between alters where `sex == "m"`)
subset(x = egor32, all(alter$sex == "m"), unit = "aatie")
Methods to print and summarize egor
objects
Description
Methods to print and summarize egor
objects
Usage
## S3 method for class 'egor'
summary(object, ...)
## S3 method for class 'egor'
print(
x,
...,
n.active = getOption("egor.rows_active_level"),
n.inactive = getOption("egor.rows_inactive_level")
)
Arguments
object , x |
an |
... |
additional arguments, either unused or passed to lower-level functions. |
n.active |
|
n.inactive |
|
n |
Number of rows to print. |
Read/ import ego-centered network data from the three files format, EgoWeb2.0 or openeddi.
Description
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 |
|
alters.df |
|
edges |
|
ID.vars |
A named list containing column names of the relevant input columns:
|
ego.vars |
A |
... |
additional arguments to |
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 |
|
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 byread_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 providedread_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.
# Fetch current working directory
wd <- getwd()
setwd(system.file("extdata", "openeddi", package = "egor"))
oe <- read_openeddi()
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)
Transnational personal communities of social support of German migrants in Great Britain
Description
This is an egor
object derived from a subset of the data of a personal network
study on support relationships German migrants living in the UK maintain. The data was collected in 2010 using respondent driven sampling (snowball sampling).
While the number of alters the respondents were allowed to enter was not limited, only a random subsample of up to eight alters were selected for the alter name interpreter and alter-alter tie questions.
This data set contains the data
for 50 of the originally 234 egos.
Usage
transnat
alter_df
ego_df
Format
transnat: an egor
object of 50 egos.
alter_df: alter data.frame
of the transnat dataset.
ego_df: ego data.frame
of the transnat dataset.
Details
The questionnaire used seven name generators:
From time to time, people rely on other people's advice and opinions to help them find their way in life better. In the last 12 months, who have you sought advice from when it came to important decisions, for example about your family or work? (emotional)
In the last 12 months who has done little jobs and favors for you or helped you, for example in filling in forms or moving home? (instrumental)
In the past year, who have you turned to when you felt down and wanted someone to talk to? (emotional)
In the last 12 months, who have you borrowed money from? (instrumental)
In the past year, who have you spent your free time with or shared a hobby? ( social companionship)
In the past year who have you had disagreements or arguments with (e.g. about everyday affairs, money or property)? (conflict)
Who has let you know that you can rely on them (e.g. that they will always be there for you if you need help)? (emotional).
References
Herz, A. (2015). Relational constitution of social support in migrants' transnational personal communities. Social Networks, 40 (1), S. 64-74.
Herz, A. (2012). Strukturen transnationaler sozialer Unterstützung. Springer Fachmedien Wiesbaden.
Trims alter-alter ties of alters that are missing/ deleted from alters data.
Description
This is used in the background by dplyr
methods, to maintain the alter-alter
ties according to changes made to the ego and alter data levels.
Usage
trim_aaties(object)
Arguments
object |
An |
Value
An egor
object with trimmed alter-alter ties (.aaties).
Trims alters that are missing/ deleted from ego data.
Description
This is used in the background by dplyr
methods, to maintain the alter
ties according to changes made to the ego data level.
Usage
trim_alters(object)
Arguments
object |
An |
Value
An egor
object with trimmed alter-alter ties (.aaties).
Import ego-centered network data from two file format
Description
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 |
|
alters |
|
ID.vars |
A named list containing column names of the relevant input columns:
|
max.alters |
Maximum number of alters that are included in edge data. |
aa.first.var |
Index or name of the first column in |
selection |
|
... |
additional arguments to |
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")
Visualize clustered graphs
Description
vis_clustered_graphs
visualizes clustered_graphs using a list of
clustered graphs created with clustered_graphs
.
Usage
vis_clustered_graphs(
graphs,
node.size.multiplier = 1,
node.min.size = 0,
node.max.size = 200,
normalise.node.sizes = TRUE,
edge.width.multiplier = 1,
center = 1,
label.size = 0.8,
labels = FALSE,
legend.node.size = 45,
pdf.name = NULL,
...
)
Arguments
graphs |
|
node.size.multiplier |
|
node.min.size |
|
node.max.size |
|
normalise.node.sizes |
|
edge.width.multiplier |
|
center |
|
label.size |
|
labels |
|
legend.node.size |
|
pdf.name |
|
... |
Arguments to pass to |
Value
vis_clustered_graphs
plots
a list
of igraph
objects created by the clustered_graphs
function.
clustered_graphs
returns a list of graph objects representing
the clustered ego-centered network data;
References
Brandes, U., Lerner, J., Lubbers, M. J., McCarty, C., & Molina, J. L. (2008). Visual Statistics for Collections of Clustered Graphs. 2008 IEEE Pacific Visualization Symposium, 47-54.
See Also
clustered_graphs
for creating clustered graphs objects
Examples
data("egor32")
# Simplify networks to clustered graphs, stored as igraph objects
graphs <- clustered_graphs(egor32, "country")
# Visualise
par(mfrow = c(2,3))
vis_clustered_graphs(
graphs[1:5]
)
par(mfrow = c(1,1))
weights.egor()
extracts the (relative) sampling weights of each
ego in the dataset.
Description
weights.egor()
extracts the (relative) sampling weights of each
ego in the dataset.
Usage
## S3 method for class 'egor'
weights(object, ...)
Arguments
object |
an |
... |
arguments to be passed to methods |
See Also
Transform wide alter-alter data to an edge list. When alter-alter for numerous networks is stored in one file/object it is common use the 'wide' data format. This function transforms such data to an edge lists.
Description
Transform wide alter-alter data to an edge list. When alter-alter for numerous networks is stored in one file/object it is common use the 'wide' data format. This function transforms such data to an edge lists.
Usage
wide.dyads.to.edgelist(
e.wide,
first.var,
max.alters,
alters.list = NULL,
selection = NULL
)
Arguments
e.wide |
A dataframe containing the alter-alter relation data in the 'wide' format. |
first.var |
Number of column containing the relation between the first and the second network contact. |
max.alters |
Maximum number of alters for which alter-alter relations were collected. |
Transform wide alter-alter data to an edge list. A regex based implementation to convert a wide list to an edgelist.
Description
Transform wide alter-alter data to an edge list. A regex based implementation to convert a wide list to an edgelist.
Usage
wide.dyads.to.edgelist.regex(e.wide, aa.regex, netsize)
Arguments
e.wide |
A dataframe containing the alter-alter relation data in the 'wide' format. |
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: |
netsize |
|
Transform 'wide' alter-level data to the 'long'-format
Description
A function to transform a wide-format dataframe of ego-centered network data into a long-format data-frame, where every row represents one alter/dyad. In the created dataframe numerous networks can be distinguished by a network ID (egoID).
Usage
wide.to.long(
wide,
egoID = "egoID",
max.alters,
start.col,
end.col,
var.wise = FALSE
)
Arguments
wide |
A |
egoID |
|
max.alters |
A |
start.col |
Index or name of the first column containing alter-alter relation data.
#!# Should: Defaults to first column of |
end.col |
Index or name of the first column containing alter-alter relation data.
#!# Should: Defaults to last column of |
var.wise |
a logical value indicating whether the alter attributes are stored variable-wise, if FALSE alter-wise storage is assumed. |