Decompose a netify object into edges and nodal data frames
decompose_netlet.Rd
decompose_netlet
separates a netify object into its constituent parts:
a data frame of edges and a data frame of nodal attributes. This function
is particularly useful for preparing network data for analyses that
require separate edge and node data sets.
Value
A list containing two elements: edge_data
and nodal_data
.
edge_data
is a data frame of edges with attributes, and
nodal_data
is a data frame containing node attributes.
Examples
# load icews data
data(icews)
# choose attributes
nvars = c( 'i_polity2', 'i_log_gdp', 'i_log_pop' )
dvars = c( 'matlCoop', 'verbConf', 'matlConf' )
# create a netify object
netlet = netify(
dyad_data=icews, actor1='i', actor2='j',
time = 'year',
symmetric=FALSE, weight='verbCoop',
mode='unipartite', sum_dyads=FALSE,
actor_time_uniform=TRUE, actor_pds=NULL,
diag_to_NA=TRUE, missing_to_zero=TRUE,
nodal_vars = nvars,
dyad_vars = dvars
)
# decompose the netify object
decomposed = decompose_netlet( netlet )
lapply(decomposed, head)
#> $edge_data
#> from to time verbCoop matlCoop verbConf matlConf
#> 1 Afghanistan Albania 2002 6 1 0 0
#> 2 Afghanistan Albania 2003 1 1 0 0
#> 3 Afghanistan Albania 2004 10 2 0 1
#> 4 Afghanistan Albania 2006 6 2 3 21
#> 5 Afghanistan Albania 2007 3 2 0 0
#> 6 Afghanistan Albania 2008 2 0 0 0
#>
#> $nodal_data
#> name time i_polity2 i_log_gdp i_log_pop
#> 1 Afghanistan 2002 NA 22.74550 16.86005
#> 2 Afghanistan 2003 NA 22.83014 16.93546
#> 3 Afghanistan 2004 NA 22.84418 16.97479
#> 4 Afghanistan 2005 NA 22.95061 17.01055
#> 5 Afghanistan 2006 NA 23.00280 17.05195
#> 6 Afghanistan 2007 NA 23.13230 17.06988
#>