[R] data frame returned from sapply but vector expected

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Nov 4 13:30:27 CET 2022


On Fri, 4 Nov 2022 12:19:09 +0000
PIKAL Petr <petr.pikal using 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.847

Is sapply(mylist2, `[[`, 'b') closer to what you'd like to see, i.e. a
list of vectors or NULLs?

-- 
Best regards,
Ivan



More information about the R-help mailing list