[R] Selecting first 7 elements

Kang Min ngokangmin at gmail.com
Sun May 23 08:28:17 CEST 2010


Hi,

I have a list of 100, each list has 20 elements, and I would like to
select the first 7 elements in each list.
Let's take the alphabet as an example.

x <- lapply(1:100, function(i) sample(LETTERS))

I tried x[[1:7]], but it doesn't work. Can anyone enlighten me on how
to do such selections?

Thank you.

Kang Min



More information about the R-help mailing list