Learn R Programming

xergm (version 1.5.3)

adjust: Adjust the dimensions of a matrix to the dimensions of another matrix

Description

Adjust the dimensions of a matrix to the dimensions of another matrix.

Usage

adjust(source, target, remove = TRUE, add = TRUE, value = NA, 
    returnlabels = FALSE)

Arguments

source
A matrix, network, list or data.frame object or a vector which should be adjusted.
target
A matrix, network, list or data.frame object or a vector to which the source object is compared with regard to its labels.
remove
Should rows and columns that are not present in the target object be removed?
add
Should rows and columns that are present in the target object but not in the source object be added to the source object?
value
The value to be inserted if a new row or column is added. By default, new cells are filled with NA values, but other sensible values may include -Inf or 0.
returnlabels
Return a list of added and removed row and column labels rather than the actual matrix, vector, or network object?

Details

An adjacency matrix (the source matrix) is compared to another adjacency matrix (the target matrix) by matching the row or column labels. If the target matrix contains rows/columns which are not present in the source matrix, new rows and columns with the corresponding labels and NA values in the cells are inserted into the source matrix. If the source matrix contains rows/columns which are not present in the target matrix, these rows and columns are removed from the source matrix. In addition to adjacency matrices, two-mode matrices, network objects (also with vertex attributes), and vectors are supported.

See Also

xergm-package handleMissings preprocess