[R] problem with lists...
A.R. Ebrahimi
a.ebrahimi at ieee.org
Tue Dec 5 12:48:28 CET 2006
Hi guys,
I am new to R, so sorry if my problem seems trivial.
Sometimes I encounter some lists, which I cannot index their components
with [ . ]
For instance the prcomp() function returns a 'prcomp' object whose
components are some 'lists'. the second component is a list that
comtains the following:
> mylist <- churn[2]
> class(mylist)
[1] "list"
> mylist
PC1 PC2
PC3 PC4 PC5 PC6
Account_Length -8.930570e-03 2.383719e-03 -2.414908e-02
-1.004704e-01 9.941468e-01 2.867606e-02
Area_Code 1.543767e-02 -1.710566e-02 -6.258129e-03
9.945271e-01 1.008478e-01 -8.890155e-03
Intl_Plan -2.627796e-04 -1.809011e-04
-9.542965e-05 3.230055e-04 2.148520e-04 -1.622996e-05
VMail_Plan 4.879640e-06 -1.339026e-04 1.639344e-04
-1.367628e-05 2.897648e-05 5.548126e-04
VMail_Message -4.174810e-04 -2.969518e-03 4.791422e-03
-5.643246e-04 -1.752559e-03 1.433728e-02
Day_Mins -9.845791e-01 2.049519e-02 -4.038624e-02
1.619195e-02 -8.308484e-03 4.217712e-04
Day_Calls -2.810874e-03 1.428161e-02 2.837638e-03
-7.647877e-03 2.532260e-02 -9.431350e-01
Day_Charge -1.673781e-01 3.483165e-03 -6.864827e-03
2.752626e-03 -1.412836e-03 7.042886e-05
Eve_Mins -4.029002e-02 -8.265860e-01 5.544912e-01
-1.166711e-02 1.426697e-02 -1.087738e-02
It look more like a matrix!
but I cannot access individual items in this list.
> mylist[1]
'returns the whole think'
> mylist[1,1]
Error in mylist[1, 1] : incorrect number of dimensions
> mylist[2]
$<NA>
NULL
Would you please help me on this
Regards
More information about the R-help
mailing list