mapClass: Correspondence between classifications

Description Usage Arguments Value See Also Examples

View source: R/util.R

Description

Best correspondence between classes given two vectors viewed as alternative classifications of the same object.

Usage

1
mapClass(a, b)

Arguments

a

A numeric or character vector of class labels.

b

A numeric or character vector of class labels. Must have the same length as a.

Value

A list with two named elements, aTOb and bTOa which are themselves lists. The aTOb list has a component corresponding to each unique element of a, which gives the element or elements of b that result in the closest class correspondence.

The bTOa list has a component corresponding to each unique element of b, which gives the element or elements of a that result in the closest class correspondence.

See Also

classError, table

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
a <- rep(1:3, 3)
a
b <- rep(c("A", "B", "C"), 3)
b
mapClass(a, b)
a <- sample(1:3, 9, replace = TRUE)
a
b <- sample(c("A", "B", "C"), 9, replace = TRUE)
b
mapClass(a, b)

Example output

Package 'mclust' version 5.4.3
Type 'citation("mclust")' for citing this R package in publications.
[1] 1 2 3 1 2 3 1 2 3
[1] "A" "B" "C" "A" "B" "C" "A" "B" "C"
$aTOb
$aTOb$`1`
[1] "A"

$aTOb$`2`
[1] "B"

$aTOb$`3`
[1] "C"


$bTOa
$bTOa$A
[1] 1

$bTOa$B
[1] 2

$bTOa$C
[1] 3


[1] 2 2 3 2 1 2 3 1 3
[1] "B" "B" "C" "C" "C" "A" "A" "B" "C"
$aTOb
$aTOb$`1`
[1] "B"

$aTOb$`2`
[1] "B"

$aTOb$`3`
[1] "C"


$bTOa
$bTOa$A
[1] 2

$bTOa$B
[1] 2

$bTOa$C
[1] 3

mclust documentation built on Nov. 20, 2020, 5:09 p.m.