conversion: Conversion between Representations of Responses or States

conversionR Documentation

Conversion between Representations of Responses or States

Description

Converts between binary matrix and pattern representations of response patterns or knowledge states.

Usage

as.pattern(R, freq = FALSE, useNames = FALSE, as.set = FALSE,
           sep = "", emptyset = "{}", as.letters = NULL)

as.binmat(N.R, uniq = TRUE, col.names = NULL, as.logical = FALSE)

is.subset(R)

Arguments

R

an indicator matrix of response patterns or knowledge states.

N.R

either a (named) vector of absolute frequencies of response patterns; or a character vector of response patterns or knowledge states; or a set of sets representing the knowledge structure.

freq

logical, should the frequencies of response patterns be reported?

uniq

logical, if TRUE, only the unique response patterns are returned.

useNames

logical, return response patterns as combinations of item names.

as.set

logical, return response patterns as set of sets.

sep

character to separate the item names.

emptyset

string representing the empty set if useNames is TRUE.

as.letters

deprecated, use useNames instead.

col.names

column names for the state or response matrix.

as.logical

logical, return logical matrix of states.

Value

as.pattern returns a vector of integers named by the response patterns if freq is TRUE, else a character vector. If as.set is TRUE, the return value is of class set.

as.binmat returns an indicator matrix. If as.logical is TRUE, it returns a logical matrix.

is.subset returns a logical incidence matrix of the subset relation among states.

See Also

blim, set in package sets.

Examples

data(DoignonFalmagne7)
K <- DoignonFalmagne7$K
as.pattern(K, freq = TRUE)
as.pattern(K)
as.pattern(K, useNames = TRUE)
as.pattern(K, as.set = TRUE)

N.R <- DoignonFalmagne7$N.R
dim(as.binmat(N.R))
dim(as.binmat(N.R, uniq = FALSE))

## Knowledge structure as binary matrix
as.binmat(c("000", "100", "101", "111"))
as.binmat(set(set(), set("a"), set("a", "c"), set("a", "b", "c")))
as.binmat(c("000", "100", "101", "111"), as.logical = TRUE)

## Subset relation incidence matrix
is.subset(K)

## Plotting the knowledge structure
if(requireNamespace("relations") &&
   requireNamespace("Rgraphviz")) {
  rownames(K) <- as.pattern(K, useNames = TRUE)
  plot(relations::as.relation(is.subset(K)), main = "")
}

pks documentation built on July 9, 2023, 5:43 p.m.