[R] Accessing the elements of summary(prcomp(USArrests))
Erik Iverson
eriki at ccbr.umn.edu
Wed Jun 16 21:35:14 CEST 2010
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")
More information about the R-help
mailing list