Skip to content

Instantly share code, notes, and snippets.

@wenhuizhang
wenhuizhang / PCA_R_HSI
Created October 27, 2013 20:24
PCA_R_HSI_1
#Do an R-mode using prcomp(), for correlation and covariance among variables
#for Q-mode PCA :the data set should be transposed before procceeding
#Q-mode focuses on correlations and covariance among samples
mydata<-read.table(file="/Users/WenhuiZhang/Desktop/hypeScpec_R/R_hyperspectra/mydata.txt",header=TRUE,row.name=1,sep=",")
mydata.pca<-prcomp(mydata,retx=TRUE,center=TRUE,scale.=TRUE)
#variable means set to zero, and variance set to one sample scores stored in mydata.pca$x