Re: [R] Accessing the elements of summary(prcomp(USArrests))

From: Erik Iverson <eriki_at_ccbr.umn.edu>
Date: Wed, 16 Jun 2010 14:35:14 -0500

Josh B wrote:
> Hello again,
>
> I was hoping one of you could help me with this problem. Consider the
> sample data from R:
>

>> summary(prcomp(USArrests))

> Importance of components: PC1 PC2 PC3 PC4 Standard
> deviation 83.732 14.2124 6.4894 2.48279 Proportion of Variance
> 0.966 0.0278 0.0058 0.00085 Cumulative Proportion 0.966 0.9933
> 0.9991 1.00000
>
> How do I access the information contained within this summary? For
> instance, let's say I wanted to make a graph based on the second row
> ("Proportion of Variance").
>

The easiest way is to use the ?str function to see how an object is put together.

So, assign the results of the summary to a variable

x <- summary(prcomp(USArrests))

then

str(x)

will lead you to :

plot(x$importance[2, ], type = "l")



R-help_at_r-project.org mailing list
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. Received on Wed 16 Jun 2010 - 19:45:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Jun 2010 - 19:50:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive