convert {cabootcrs} | R Documentation |
Converting a data matrix from one format into another
Description
convert
recodes a data matrix from one format, used by versions of correspondence analysis,
into another (n objects by p variables, counts for distinct combinations of p variables, indicator matrix, contingency table).
Usage
convert(
Xinput,
input = "nbyp",
output = "indicator",
Jk = NULL,
maxcat = NULL,
varandcat = TRUE
)
Arguments
Xinput |
A data matrix, in the form of a data frame or similar |
input |
The format of the input matrix:
|
output |
The format of the output matrix:
|
Jk |
A list containing the number of distinct categories for each variable. |
maxcat |
The maximum category value, for use when all variables are Likert on a scale of 1 to maxcat. |
varandcat |
Flag for how to construct column names in an indicator matrix:
|
Value
A list containing:
- result
the output data matrix formatted according to the output argument
- varnames
a list of length p containing the names of each variable
- catnames
a list/array (of length p) containing the lists (of length Jk[i]) of category names for each variable
- Jk
a list of length p containing the number of distinct categories for each variable
- p
the number of variables
See Also
getBurt
to obtain a Burt matrix or a subset of an existing one
getCT
to obtain a contingency table (only if p=2)
getindicator
to obtain an indicator matrix
getdoubled
to obtain a doubled matrix if all variables are ordered categorical with numbered categories
Other conversion functions:
getBurt()
,
getCT()
,
getdoubled()
,
getindicator()
Examples
dreamdataCT <- DreamData
dreamdatanbyplist <- convert(dreamdataCT,input="CT",output="nbyp")
dreamdatanbyp <- dreamdatanbyplist$result
## Not run:
dreamdataCTb <- table(dreamdatanbyp)
dreamdatanbypcounts <- convert(dreamdatanbyp,input="nbyp",output="nbypcounts")$result
dreamdataindicatorlist <- convert(dreamdatanbypcounts,input="nbypcounts",output="indicator")
dreamdatanbypb <- convert(dreamdataindicatorlist$result,input="indicator",
output="nbyp",Jk=dreamdataindicatorlist$Jk)$result
nishdatanbyp <- NishData
nishdataindicator <- convert(nishdatanbyp)$result
nishdataBurt <- t(nishdataindicator)%*%nishdataindicator
## End(Not run)