Re: [R] Fwd: Extracting a particular column from list

2020-01-20 Thread Bert Gunter
Trickier, but shorter: > lapply(u,'[',1) $a [1] 1 $b [1] "a" Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Jan 17, 2020 at 10:04 PM Eric Berger wrote:

Re: [R] Fwd: Extracting a particular column from list

2020-01-19 Thread PIKAL Petr
Or simply lapply(u, "[", 1) $a [1] 1 $b [1] "a" Cheers Petr > -Original Message- > From: R-help On Behalf Of Eric Berger > Sent: Thursday, January 16, 2020 1:36 PM > To: R mailing list > Subject: [R] Fwd: Extracting a particular column from

[R] Fwd: Extracting a particular column from list

2020-01-17 Thread Eric Berger
[Putting back onto r-help] You could try sapply() and lapply(). > e <- sapply( 1:length(u), function(i) u[[i]][1] ) > e # [1] "1" "a"(note that the integer 1 became a character string "1") > f <- lapply( 1:length(u), function(i) u[[i]][1] ) > f [[1]] [1] 1 [[2]] [1] "a" In this case sapply