Skip to content
Prev 69768 / 398525 Next

Mental Block with PCA of multivariate time series!

Laura Quinn wrote:
Hi Laura,

data(iris)
iris.dat <- iris[,1:4]
pca.1 <- prcomp(iris.dat[1:50, ], scale = TRUE)
pca.2 <- prcomp(iris.dat[51:100, ], scale = TRUE)
pca.3 <- prcomp(iris.dat[100:150, ], scale = TRUE)

biplot(pca.1)
etc...

There is a better way of subsetting this data set as the 5th col of iris 
is a factor and we could use the subset argument to prcomp to do the 
subsetting without having to know that there are 50 rows per species. 
Take a look at that argument if you have a variable that defines the 
blocks for you.

Is this what you were after?

All the best,

Gav