catDiffs2: Differences in Categorical Variables

Description Usage Arguments Value Examples

View source: R/similarity-scores.R

Description

Computes the scaled difference between a vector of categorical variables and a matrix of categorical variables. Should not usually be called by hand. Instead, use the calcScores2 function.

Usage

1
catDiffs2(vec, dat)

Arguments

vec

a character vector. Each value in the vector corresponds to a unique variable.

dat

a character matrix or data.frame of character variables. The number of columns must be equal to the length of vec.

Value

a matrix of the same dimensions as dat. The ith entry in the jth row is 0 if the jth value of vec is equal to the jth value of the ith row of dat. It is 1 if they are different. If either the ith value of the jth row of dat or the jth value of vec are missing, and NA will be returned.

Examples

1
2
3
4
5
6
example_vec <- c("a", "b", NA)
example_dat <- matrix(c("a", "a", "a",
                        "b", "b", "b",
                        NA, "b", "a"),
                      nrow = 3, byrow = T)
catDiffs2(example_vec, example_dat)

guytuori/simScores documentation built on May 17, 2019, 9:29 a.m.