I have a very large list consisting of data frames, each list item is a different data frame, where each column consists of different types of variables and data frames of different lengths. I want to multiply the data frames in this list and store only those columns that have classes of “integer” or “numeric”, preserving the structure of the data frames (so it seems to be “no”).
What follows is MRE:
x1 <- c(1,2,3,4)
y1 <- c(letters[1:4])
z1 <- as.integer(c(0, 1, 0, 1))
df1 <- data.frame(x1,y1,z1)
str(df1)
x2 <- c(0, 1, 2, 3,4 )
y2 <- as.integer(c(0, 1, 0, 1, 0))
z2 <- c(letters[1:5])
df2 <- data.frame(x2,y2,z2)
str(df2)
list12 <- list(df1, df2)
str(list12)
My expected result is a list of two data frames: only columns containing integers or number classes
source
share