If I were to find the class of each column I would normally (assuming I'd like to avoid str):
lapply(df, class)
However, what if I wanted to do the same for multiple dataframes? E.g.:
x <- data.table(col_1 = c('a', 'b')
, col_2 = 1:2
); x
y <- data.table(col_3 = 3:4
, col_4 = c('c', 'd')
); y
My attempt is:
lapply(1:2, function(i) class( list(x,y)[[i]] ) )
but it gives:
[[1]]
[1] "data.table" "data.frame"
[[2]]
[1] "data.table" "data.frame"
i.e. R is failing to apply to the columns inside each element (in this case, each dataframe) of the list. If I am after an apply solution (especially not a For loop or str), what would that be?
Or would Reduce, Map or do.call achieve this too?
Thank you.