Is there an easy way to tell if many data frames stored in one list contain the same columns?
问题 I have a list containing many data frames: df1 <- data.frame(A = 1:5, B = 2:6, C = LETTERS[1:5]) df2 <- data.frame(A = 1:5, B = 2:6, C = LETTERS[1:5]) df3 <- data.frame(A = 1:5, C = LETTERS[1:5]) my_list <- list(df1, df2, df3) I want to know if every data frame in this list contains the same columns (i.e., the same number of columns, all having the same names and in the same order). I know that you can easily find column names of data frames in a list using lapply : lapply(my_list, colnames)