Desired
is having a R function
listNames = function(l) {
# return list element names
}
that returns all list elements, but ignores the column names of data frames on first level
listNames(a)
[1] "b.df1" "b.e" "c" "df2"
from a nested list:
a = list(b = list(df1 = data.frame(col = c(1,2)), e = NULL), c = NULL, df2 = data.frame(c12 = c(1,2),c34 = c(3,4)))
Tried so far
unlist
returns also data.frame columns. I assume because data.frames are also considered lists
names(unlist(a,recursive = FALSE))
[1] "b.df1" "b.e" "df2.c12" "df2.c34"
and names(a)
skips nested elements
names(a)
[1] "b" "c" "df2"
names(a)
? – Martin Gal