data(optdigits)
m <- length(unique(optdigits$label)) # number of classes
n <- nrow(optdigits$x) / m # number of units
## Use function with data in matrix form
fit1 <- match.rec(optdigits$x, unit=n)
## Use function with data in array form
p <- ncol(optdigits$x)
x <- t(optdigits$x)
dim(x) <- c(p,m,n)
fit2 <- match.rec(x)
Run the code above in your browser using DataLab