crosssectional_consensus_cluster {longmixr} | R Documentation |
Cross-sectional clustering with categorical variables
Description
This function uses the ConsensusClusterPlus
function from the package
with the same name with defaults for clustering data with categorical
variables. As the distance function, the Gower distance is used.
Usage
crosssectional_consensus_cluster(
data,
reps = 1000,
finalLinkage = "ward.D2",
innerLinkage = "ward.D2",
...
)
Arguments
data |
a matrix or data.frame containing variables that should be used
for computing the distance. This argument is passed to |
reps |
number of repetitions, same as in |
finalLinkage |
linkage method for final clustering,
same as in |
innerLinkage |
linkage method for clustering steps,
same as in |
... |
other arguments passed to |
Details
data
can take all input data types that gower.dist
can handle, i.e. numeric
, character
/factor
, ordered
and logical
.
Value
The output is produced by ConsensusClusterPlus
Examples
dc <- mtcars
# scale continuous variables
dc <- sapply(mtcars[, 1:7], scale)
# code factor variables
dc <- cbind(as.data.frame(dc),
vs = as.factor(mtcars$vs),
am = as.factor(mtcars$am),
gear = as.factor(mtcars$gear),
carb = as.factor(mtcars$carb))
cc <- crosssectional_consensus_cluster(
data = dc,
reps = 10,
seed = 1
)