Skip to content
Prev 18267 / 398503 Next

Extracting the first element of a list

Ross Darnell wrote:
For the first element of a list L: 
 L[[1]]
For the first elements of all elements (vector) of the list:
 lapply(L, function(x) x[1])

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._