Re: [R] apply a function to a list of lists

2023-09-20 Thread Ivan Krylov
On Tue, 19 Sep 2023 17:14:58 +0200 arnaud gaboury wrote: > non_empty_df <- function(l) { > lapply(l, function(df) df[sapply(df, function(df) nrow(df) !=0)]) > } > If I test this way: non_empty_df(my.list[1]) it does the job. It will > return the data.frame from the first list of my_list

[R] apply a function to a list of lists

2023-09-20 Thread arnaud gaboury
I have a list of 9 lists called my.list. Each one of these 9 lists is itself a list of 6 data.frames. Most of these data.frames have 0 rows and 0 columns. I want to return all data.frames from the list with row numbers different from 0. I first created the following function: non_empty_df <-