nominalAsBinet {NIMAA} | R Documentation |
Convert nominal data to a bipartite network
Description
This function converts nominal data, which is represented in a data frame format as an edge list, to a bipartite network in the incidence matrix format. Nominal data is typically a data frame with two (or three) columns representing two nominal variables labels that NIMAA considers as starting and ending nodes (labels) in an edge list (or with a numeric value for each pairwise relationship of labels). The elements in the incidence matrix are the binary or numeric values of the pairwise relationships.
Usage
nominalAsBinet(
el,
index_nominal = c(1, 2),
index_numeric = 3,
print_skim = FALSE
)
Arguments
el |
A data frame or matrix object as an edge list. |
index_nominal |
A vector with two values represents the indices for the columns containing nominal variables. The first value indicates the row objects and the second value indicates the column objects in the incidence matrix output. |
index_numeric |
An integer, the index for numeric values. This is the value used to pick the column containing the numeric values corresponding to the pairwise relationship of nominal variable labels. This column is used for missing value investigation and imputation steps. |
print_skim |
A logical value, If |
Value
The incidence matrix representing the corresponding bipartite network. If print_skim
set to TRUE
, a summary of the matrix is also provided.
See Also
pivot_wider
,
column_to_rownames
Examples
# generate a data frame with two nominal variables without numeric values
el1 <- data.frame(
nominal_var_1 = c("d", "e", "e", "b", "a", "a"),
nominal_var_2 = c("J", "N", "O", "R", "R", "L")
)
# generate a data frame with two nominal variables with numeric values
el2 <- data.frame(
nominal_var_1 = c("d", "e", "e", "b", "a", "a"),
nominal_var_2 = c("J", "N", "O", "R", "R", "L"),
numeric_val = c(4, 5, 5, 8, 7, 7)
)
# run nominalAsBinet() to convert the edge list to the incidence matrix
inc_mat1 <- nominalAsBinet(el1)
inc_mat2 <- nominalAsBinet(el2)