[R] Pulling out parts of a generated array in R

Wayne Aldo Gavioli wgavioli at fas.harvard.edu
Sat Sep 15 18:23:23 CEST 2007


Hello all,

I was wondering if it was possible to pull out certain parts of an array in R -
not an array of data that I have created, but an array of data that has been
spit out by R itself.

More specifically, in the lines of code below:


> 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



I was wondering if there is a way to only extract one piece of this array,
specifically the Proportion of Variance for PC2, which is 0.0278.  I know how
to extract one entire line of data from this array, using the following lines
of code:

> result<-summary(prcomp(USArrests))
> m<-result$importance
> final<-m[2,]


These lines of code will produce the follwing output:


0.966  0.0278 0.0058 0.00085


Now I was wondering if there is anyway to break this down even further, and be
able to extract one piece of data from this one line.

If anyone could help me out, I would really appreciate it.


Thanks,


Wayne



More information about the R-help mailing list