Hallo Ivan

Thanks, yes it seems to be working. I thought also removing NULL by

mylist2[sapply(mylist2, is.null)] <- NULL

but your approach is probably better (in any case simpler)

Thanks again.

Petr

> -----Original Message-----
> From: Ivan Krylov <krylov.r...@gmail.com>
> Sent: Friday, November 4, 2022 1:37 PM
> To: PIKAL Petr <petr.pi...@precheza.cz>
> Cc: R-help Mailing List <r-help@r-project.org>
> Subject: Re: [R] data frame returned from sapply but vector expected
> 
> On Fri, 4 Nov 2022 15:30:27 +0300
> Ivan Krylov <krylov.r...@gmail.com> wrote:
> 
> > sapply(mylist2, `[[`, 'b')
> 
> Wait, that would simplify the return value into a matrix when there are no
> NULLs. But lapply(mylist2, `[[`, 'b') should work in both cases, which in
my
> opinion goes to show the dangers of using simplifying functions in
to-be-library
> code.
> 
> Sorry for the double-post!
> 
> --
> Best regards,
> Ivan
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to