recode: Recodes an edgelist such that ids go from 1 to n

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/misc.r

Description

Recodes an edgelist such that ids go from 1 to n

Usage

1
2
3
4
5
6
7
recode(data, ...)

## S3 method for class 'data.frame'
recode(data, ...)

## S3 method for class 'matrix'
recode(data, ...)

Arguments

data

Edgelist as either a matrix or dataframe with ego and alter

...

Further arguments for the method (ignored)

Details

Required for using most of the package's functions, as ids are used as a reference for accessing elements in adjacency matrices.

Value

A recoded edgelist as a two-column matrix/data.frame depending on the class of data. The output includes an attribute called "recode" which contains a two column data.frame providing a mapping between the previous code and the new code (see the examples)

Author(s)

George G. Vega Yon

See Also

edgelist_to_adjmat

Examples

1
2
3
4
5
6
7
8
# Simple example ------------------------------------------------------------
edgelist <- cbind(c(1,1,3,6),c(4,3,200,1))
edgelist
recoded_edgelist <- recode(edgelist)
recoded_edgelist

# Retrieving the "recode" attribute
attr(recoded_edgelist, "recode")

srdyal/diffusiontest documentation built on July 31, 2018, 2:14 a.m.