[R] Problems with principal components analysis PCA with prcomp

Sarah Goslee sarah.goslee at gmail.com
Thu Nov 16 15:09:39 CET 2006


Hello Carlos,

# let me save you a couple steps here
> x<-read.table("test.txt", header=T, row.names=1)

> pca<-prcomp(x, scale=T)
> names(pca)
>
> ## here begin my problems… know what…??##

Try this for a graphical view of your data:
biplot(pca)
You might also want to work through the examples given
in ?prcomp and ?princomp.

> My questions are:
> 1. How can I group my samples (rows) in a graphical way?
> 2. How can I extract the samples related to each group? …or… How can I
> create a new column with "n" values corresponding to each group created?

Here I see a problem... if you are interested in _groups_ in the data, you
might be better off with a clustering method, of which R has an abundance.
Ordination is generally about _gradients_ rather than groups - continuous
change vs discrete groups.

If you are determined to divide your ordination into groups, one possibility
is to use conditional subsetting on the ordination values.

> 3. Is it possible to extract/export the information in an object into a file
> with a dbf extension (e.g. test.dbf)?

help.search(dbf) finds the function write.dbf - sounds suspiciously useful.


Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list