On Fri, 4 Nov 2022 12:19:09 +0000 PIKAL Petr <petr.pikal at precheza.cz> wrote:> > str(sapply(mylist2, "[", "b")) > > List of 3 > > $ : NULL > > $ :'data.frame': 5 obs. of 1 variable: > > ..$ b: num [1:5] 0.01733 0.46055 0.19421 0.11609 0.00789 > > $ :'data.frame': 5 obs. of 1 variable: > > ..$ b: num [1:5] 0.593 0.478 0.299 0.185 0.847Is sapply(mylist2, `[[`, 'b') closer to what you'd like to see, i.e. a list of vectors or NULLs? -- Best regards, Ivan
On Fri, 4 Nov 2022 15:30:27 +0300 Ivan Krylov <krylov.r00t at 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