Thanks David!!! You have helped me tremendously! Thanks to all others for their input. I'll get out of your hair now :)
On Monday, November 30, 2015 10:48 AM, David L Carlson <dcarl...@tamu.edu> wrote: If it is just a plot of the variables by their loadings on the first two components, this should do it: > dat <- data.frame(matrix(rnorm(100), 10, 5)) > dat.pca <- prcomp(dat) > plot(dat.pca$rotation[, 1:2]) > text(dat.pca$rotation[, 1:2], colnames(dat), pos=3) Or if you don't want the symbols just the names, change the last two lines: > plot(dat.pca$rotation[, 1:2], type="n") > text(dat.pca$rotation[, 1:2], colnames(dat)) ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Boris Steipe Sent: Monday, November 30, 2015 9:01 AM To: debra ragland Cc: r-help Subject: Re: [R] PCA plot of variable names only 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. > 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.ste...@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@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@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. > > > ______________________________________________ R-help@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. [[alternative HTML version deleted]] ______________________________________________ R-help@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.