plot.kproto: Assign k-Prototypes Clusters

View source: R/kprototypes.R

plot.kprotoR Documentation

Assign k-Prototypes Clusters

Description

Plot distributions of the clusters across the variables.

Usage

## S3 method for class 'kproto'
plot(x, ...)

Arguments

x

Object resulting from a call of kproto.

...

Additional arguments to be passet to clprofiles such as e.g. vars.

Details

Wrapper around clprofiles. Only works for kproto object created with keep.data = TRUE.

Author(s)

gero.szepannek@web.de

Examples

# generate toy data with factors and numerics

n   <- 100
prb <- 0.9
muk <- 1.5 
clusid <- rep(1:4, each = n)

x1 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x1 <- c(x1, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x1 <- as.factor(x1)

x2 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x2 <- c(x2, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x2 <- as.factor(x2)

x3 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))
x4 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))

x <- data.frame(x1,x2,x3,x4)

# apply k-prototyps
kpres <- kproto(x, 4)
plot(kpres, vars = c("x1","x3")) 



clustMixType documentation built on Dec. 28, 2022, 1:09 a.m.