netwrite | R Documentation |
netwrite
)The netwrite
function reads in relational data of several formats and processes them into a set of standardized outputs. These outputs include sets of commonly calculated measures at the individual node and network-wide levels.
netwrite(
data_type = c("edgelist"),
adjacency_matrix = FALSE,
adjacency_list = FALSE,
nodelist = FALSE,
node_id = NULL,
i_elements = FALSE,
j_elements = FALSE,
fix_nodelist = TRUE,
weights = NULL,
type = NULL,
remove_loops = FALSE,
missing_code = 99999,
weight_type = "frequency",
directed = FALSE,
net_name = "network",
shiny = FALSE,
output = c("graph", "largest_bi_component", "largest_component", "node_measure_plot",
"nodelist", "edgelist", "system_level_measures", "system_measure_plot"),
message = TRUE
)
data_type |
A character value indicating the type of relational data being entered into |
adjacency_matrix |
If |
adjacency_list |
If |
nodelist |
Either a vector of values indicating unique node/vertex IDs, or a data frame including all information about nodes in the network. If the latter, a value for |
node_id |
If a data frame is entered for the |
i_elements |
If |
j_elements |
If |
fix_nodelist |
If |
weights |
A numeric vector indicating the weight of ties in the edgelist. |
type |
A numeric or character vector indicating the types of relationships represented in the edgelist. If |
remove_loops |
A logical value indicating whether "self-loops" (ties directed toward oneself) should be considered valid ties in the network being processed. |
missing_code |
A numeric value indicating "missing" values in an edgelist. Such "missing" values are sometimes included to identify the presence of isolated nodes in an edgelist when a corresponding nodelist is unavailable. |
weight_type |
A character value indicating whether edge weights should be treated as frequencies or distances. Available options are |
directed |
A logical value indicating whether edges should be treated as a directed or undirected when constructing the network. |
net_name |
A character value indicating the name to which network/igraph objects should be given. |
shiny |
A logical value indicating whether |
output |
A character vector indicating the kinds of objects |
message |
A logical value indicating whether warning messages should be displayed in the R console during processing. |
netwrite
returns a list containing several output objects. Users may find it easier to access and work with outputs by applying list2env to this list, which will separate outputs and store them in the R Global Environment. Note, however, that this risks overwriting existing objects in the Global Environment should those objects share names with objects in netwrite
's output. Depending on the values assigned to the output
argument, netwrite
will produce any or all of the following:
If output
contains graph
, netwrite
will return an igraph object of the network represented in the original data.
If a vector is entered into the type
argument, netwrite
also produces a list containing igraph objects for each unique relation type as well as the overall network. These output objects are named according to the value specified in the net_name
argument.
If output
contains "nodelist"
, netwrite
will return a dataframe containing individual-level information for each node in the network. This dataframe contains a set of frequently used node-level measures for each node in the network. If a vector is entered into the type
argument, netwrite
will produce these node-level measures for each unique relation type.
If output
contains "edgelist"
, netwrite
will return a formatted edgelist for the network represented in the original data. If a vector is entered into the type
argument, netwrite
also produces a list containing edgelists for each unique relation type as well as the overall network.
If output
contains "system_level_measures"
, netwrite
will return a data frame providing network-level summary information.
If output
contains "node_measure_plot"
, netwrite
will return a plot summarizing the distribution of frequently used node-level measures across all nodes in the network. If a vector is entered into the type
argument, netwrite
also produces a list containing node-level summary plots for each unique relation type as well as the overall network.
If output
contains "system_measure_plot"
, netwrite
will return a plot summarizing the distribution of frequently used network-level measures. If a vector is entered into the type
argument, netwrite
also produces a list containing network-level summary plots for each unique relation type as well as the overall network.
If output
contains "largest_bi_component"
, netwrite
will return an igraph object of the largest bicomponent in the network represented in the original data. If a vector is entered into the type
argument, netwrite
also produces a list containing the largest bicomponent for each unique relation type as well as the overall network.
If output
contains "largest_bi_component"
, netwrite
will return an igraph object of the largest main component in the network represented in the original data. If a vector is entered into the type
argument, netwrite
also produces a list containing the largest main component for each unique relation type as well as the overall network.
# Use netwrite on an edgelist
nw_fauxmesa <- netwrite(nodelist = fauxmesa_nodes,
node_id = "id",
i_elements = fauxmesa_edges$from,
j_elements = fauxmesa_edges$to,
directed = TRUE,
net_name = "faux_mesa")
### Inspect updated edgelist
head(nw_fauxmesa$edgelist)
### Inspect data frame of node-level measures
head(nw_fauxmesa$node_measures)
### Inspect system-level summary
head(nw_fauxmesa$system_level_measures)
### Plot sociogram of network
plot(nw_fauxmesa$faux_mesa)
### View node-level summary visualization
nw_fauxmesa$node_measure_plot
### View system-level summary visualization
nw_fauxmesa$system_measure_plot
# Run netwrite on an adjacency matrix
nw_triad <- netwrite(data_type = "adjacency_matrix",
adjacency_matrix = triad,
directed = TRUE,
net_name = "triad_igraph")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.