[R] PCA plot of variable names only
Boris Steipe
boris.steipe at utoronto.ca
Mon Nov 30 15:25:28 CET 2015
Your description is obscure but the following may get you started. The function prcomp() returns a list in which the matrix x contains the rotated values of your input. Assuming that your "variable names" are the rownames of your input, you can plot them with text().
Something like (untested):
myPCA <- prcomp(someData)
plot(myPCA$x[,1], myPCA$x[,2], type = "n")
text(myPCA$x[,1], myPCA$x[,2], rownames(someData))
B.
On Nov 30, 2015, at 8:56 AM, debra ragland via R-help <r-help at r-project.org> wrote:
> Hello,
>
> A colleague of mine prepared a PCA plot of my data and I have no clue how he did it. My original data set contains 15 variables and 64 observations. I have been trying to figure out how he did it on my own, and I have asked but he's swamped so his response is taking longer than usual. Anywho, the plot is simply of PC1 vs. PC2 and in the area of the plot there are just the variable names aligned with values I'm guessing are the loadings (?) I have been searching around and I do not think that this was done via biplot. I am also not sure what is normally plotted on a PCA plot of this type (e.g. loadings, scores, sdevs -- no clue). Again, the 15 variable names (var1, var2, var3 etc) are all that is contained in this plot, aligned with their respective values projected onto the first 2 PCs.
>
> Any idea on how to generate such a plot based on this description?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list