[R] Accessing the elements of a list

From: Shubha Vishwanath Karanth <shubhak_at_ambaresearch.com>
Date: Fri, 1 Feb 2008 14:35:02 +0530


Hi R,  

I wanted to know how do we access the elements of a list. In particular,  

v=list(c(1,2,3,4,5),c(1,2,33,4,5),c(1,2,333,4,5),c(1,2,3333,4,5))  

I want to access all the thirds items of the elements of the list. i.e., I want to access the elements, 3,33,333,3333. This can be done through sapply as:  

sapply(v,function(x) x[3])  

But I need to access this without using 'sapply'. Like in a data frame, we do df[2,3] etc.... Any ideas?    

BR, Shubha

This e-mail may contain confidential and/or privileged i...{{dropped:13}}



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 Fri 01 Feb 2008 - 09:13:37 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 Fri 01 Feb 2008 - 11:30:10 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