compare_mat: Comparison of two matrices

View source: R/compare_mat.R

compare_matR Documentation

Comparison of two matrices

Description

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

Usage

compare_mat(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).

Examples

# # Import data
nav <- read.csv(system.file("csv/nav.csv", package = "flows"))
mat <- prepare_mat(x = nav, i = "i", j = "j", fij = "fij")
# Remove the matrix diagonal
diag(mat) <- 0

# Select the first flows
flowSel1 <- select_flows(mat = mat, method = "nfirst", k = 1)

# Select flows greater than 2000
flowSel2 <- select_flows(mat = mat, method = "xfirst", k = 2000)

# Combine selections
flowSel <- mat * flowSel1 * flowSel2

# Compare flow matrices
compare_mat(mat1 = mat, mat2 = flowSel, digits = 1)

rCarto/flows documentation built on May 10, 2024, 11:38 a.m.