i want to reduce the dimension of the MNIST data to 45.
i use keras to import MNIST data
library(keras)
mnist <- dataset_mnist()
X <- mnist$train$x
Xreduced <- X / 255
pcaX <- princomp(Xreduced)
Xfinal <- as.matrix(Xreduced) %*% pcaX$loadings[,1:45]
this last line of code isnt running. i also tried "prcomp" instead of "printcomp" with same issue
error message says
Error in pcaX$loadings[, 1:45] : subscript out of bounds