## Not run:
# set.seed(1234)
# require(MASS) # generate synthetic Gaussian data
# k = 100 # sample size of each class
# n = 3 # specify how many class
# N = k * n # total sample number
# x1 = mvrnorm(k, mu = c(-10, 6), matrix(c(10, 4, 4, 10), ncol = 2))
# x2 = mvrnorm(k, mu = c(0, 0), matrix(c(10, 4, 4, 10), ncol = 2))
# x3 = mvrnorm(k, mu = c(10, -6), matrix(c(10, 4, 4, 10), ncol = 2))
# x = as.data.frame(rbind(x1, x2, x3))
# x$V3 = gl(n, k)
#
# # The fully labeled data set with 3 classes
# plot(x$V1, x$V2, bg = c("#E41A1C", "#377EB8", "#4DAF4A")[x$V3],
# pch = c(rep(22, k), rep(21, k), rep(25, k)))
# Sys.sleep(3)
#
# # Same data unlabeled; clearly the classes' structure is less evident
# plot(x$V1, x$V2)
# Sys.sleep(3)
#
# chunk1 = sample(1:100, 5)
# chunk2 = sample(setdiff(1:100, chunk1), 5)
# chunk3 = sample(101:200, 5)
# chunk4 = sample(setdiff(101:200, chunk3), 5)
# chunk5 = sample(201:300, 5)
# chks = x[c(chunk1, chunk2, chunk3, chunk4, chunk5), ]
# chunks = list(chunk1, chunk2, chunk3, chunk4, chunk5)
#
# # The chunklets provided to the RCA algorithm
# plot(chks$V1, chks$V2, col = rep(c("#E41A1C", "#377EB8",
# "#4DAF4A", "#984EA3", "#FF7F00"), each = 5),
# pch = rep(0:4, each = 5), ylim = c(-15, 15))
# Sys.sleep(3)
#
# # Whitening transformation applied to the chunklets
# chkTransformed = as.matrix(chks[ , 1:2]) %*% rca(x[ , 1:2], chunks)$A
#
# plot(chkTransformed[ , 1], chkTransformed[ , 2], col = rep(c(
# "#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00"), each = 5),
# pch = rep(0:4, each = 5), ylim = c(-15, 15))
# Sys.sleep(3)
#
# # The origin data after applying the RCA transformation
# plot(rca(x[ , 1:2], chunks)$newX[, 1], rca(x[ , 1:2], chunks)$newX[, 2],
# bg = c("#E41A1C", "#377EB8", "#4DAF4A")[gl(n, k)],
# pch = c(rep(22, k), rep(21, k), rep(25, k)))
#
# # The RCA suggested transformation of the data, dimensionality reduced
# rca(x[ , 1:2], chunks)$A
#
# # The RCA suggested Mahalanobis matrix
# rca(x[ , 1:2], chunks)$B
# ## End(Not run)
Run the code above in your browser using DataLab