flows (version 1.1.1)

compmat: Comparison of Two Matrices

Description

Compares two matrices of same dimension, with same column and row names.

Usage

compmat(mat1, mat2, digits = 0)

Arguments

mat1
A square matrix of flows.
mat2
A square matrix of flows.
digits
An integer indicating the number of decimal places to be used when printing the data.frame in the console (see round).

Value

A data.frame that provides statistics on differences between mat1 and mat2: absdiff are the absolute differences and reldiff are the relative differences (in percent).

See Also

statmat

Examples

Run this code
# Import data
data(nav)
myflows <- prepflows(mat = nav, i = "i", j = "j", fij = "fij")

# Remove the matrix diagonal
diag(myflows) <- 0

# Select the dominant flows (incoming flows criterion)
flowSel1 <- domflows(mat = myflows, w = colSums(myflows), k = 1)
# Select the first flows
flowSel2 <- firstflows(mat = myflows, method = "nfirst", ties.method = "first",
                       k = 1)
# Select flows greater than 2000
flowSel3 <- firstflows(mat = myflows, method = "xfirst", k = 2000)

# Combine selections
flowSel <- myflows * flowSel1 * flowSel2 * flowSel3

# Compare flow matrices
compmat(mat1 = myflows, mat2 = flowSel, digits = 1)

Run the code above in your browser using DataCamp Workspace