Here is a reproducible example :
set.seed(10) pick <- sample(nrow(iris),nrow(iris)/2) iris.training <- iris[pick,] iris.testing <- iris[-pick,] pca.