## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 6,
  out.width = "90%"
)

## -----------------------------------------------------------------------------
library(mccca)
data(mealDrink)

## -----------------------------------------------------------------------------
active <- c(1, 2)
external <- c(3, 4)
dat.act <- mealDrink[, active]
dat.ext <- mealDrink[, external]

## -----------------------------------------------------------------------------
head(dat.act)
head(dat.ext)

## -----------------------------------------------------------------------------
mcccadata <- create.MCCCAdata(dat.act, dat.ext)

## -----------------------------------------------------------------------------
summary(mcccadata)

## -----------------------------------------------------------------------------
K.vec <- c(2, 1, 2, 2)
set.seed(1)
res <- MCCCA(mcccadata, K.vec = K.vec)

## ----fig.alt = "MCCCA biplot of the mealDrink data showing category points for meal and drink and bubbles for the seven class-specific clusters."----
shortlabels <- c("AF", "AM", "JF", "JM")
plot(res, classlabel = shortlabels)

## -----------------------------------------------------------------------------
summary(res)

## -----------------------------------------------------------------------------
res$inertia

## -----------------------------------------------------------------------------
K.vec <- c(1, 1, 1, 1)
res.ave <- MCCCA(mcccadata, K.vec = K.vec)

## ----fig.alt = "Biplot of the averaging approach for the mealDrink data with one bubble per class."----
plot(res.ave, classlabel = shortlabels, main = "Averaging result")

