[R] PCA plot of variable names only
Boris Steipe
boris.steipe at utoronto.ca
Mon Nov 30 16:00:32 CET 2015
Please keep communications on list.
This is too confused to continue productively.
See here: http://adv-r.had.co.nz/Reproducibility.html
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
... and please read the posting guide and don't post in HTML.
On Nov 30, 2015, at 9:49 AM, debra ragland <ragland.debra at yahoo.com> wrote:
> Hi,
>
> I've tried this -- before your suggestion -- R throws an error at the plot argument stating that the figure margins are too large and the text argument staring that there is an invalid graphics state.
>
> The figure that I am referring to is similar to figure 4 here;
> Computing and visualizing PCA in R
>
>
>
>
>
>
>
>
>
> Computing and visualizing PCA in R
> Following my introduction to PCA, I will demonstrate how to apply and visualize PCA in R. There are many packages and functions that can apply PCA in R. In this po...
> View on www.r-bloggers.com
> Preview by Yahoo
>
> Without the circle (or gray background, but this is minor) enclosing the variables. I am currently trying to figure out how to the adapt the code to my needs but I am struggling.
>
>
>
> On Monday, November 30, 2015 9:25 AM, Boris Steipe <boris.steipe at utoronto.ca> wrote:
>
>
> 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