[R] Howto access object of object

Carlos J. Gil Bellosta cgb at datanalytics.com
Wed Jan 14 09:44:28 CET 2009


Hello, 

Use "@" instead of "$" to extract slots from a S4 object.

Regards,

Carlos J. Gil Bellosta
http://www.datanalytics.com


On Wed, 2009-01-14 at 17:07 +0900, Gundala Viswanath wrote:
> Dear all,
> 
> I have the following object:
> 
> > print(x)
> An object of class "matrix.csr"
> Slot "ra":
>  [1] 0.992056718 1.000000000 1.000000000 1.000000000 1.000000000 1.000000000
>  [7] 1.000000000 1.000000000 1.000000000 1.000000000 1.000000000 1.000000000
> [13] 1.000000000 1.000000000 1.000000000 1.000000000 1.000000000 1.000000000
> [19] 1.000000000 1.000000000 1.000000000 0.002647761 0.000882587 0.000882587
> [25] 0.000882587 0.000882587 0.000882587 0.000882587
> 
> Slot "ja":
>  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
> 
> Slot "ia":
>   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 22 22 22
>  [26] 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
>  [51] 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
>  [76] 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22
> 
> Slot "dimension":
> [1] 100   1
> 
> __ END__
> 
> How can I acces "Slot 'ra'" only?
> 
> I tried
> 
> print(x$ra)
> 
> but fail.
> 
> - Gundala Viswanath
> Jakarta - Indonesia
> 
> ______________________________________________
> 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.




More information about the R-help mailing list