-1

I'm seeking to combine 10 separate dataframes together within a list of data frames I created from a standard for loop procedure. However every column name in each dataframe is unique. I don't seek to bind any columns into other columns. I simply want to place all columns next to each other. So rbind didn't work for me.

> do.call(rbind, data)
Error in match.names(clabs, names(xi)) : 
  names do not match previous names

Any help would be appreciated thank you.

srb633
  • 793
  • 3
  • 8
  • 16
  • This looks similar https://stackoverflow.com/questions/28566588/r-rbind-data-frames-with-a-different-column-name Did you try the solutions there? – Ronak Shah Apr 03 '20 at 08:43
  • rbindlist didn't work. "Error in rbindlist(data) : Item 10 has 1 columns, inconsistent with item 1 which has 5 columns. To fill missing columns use fill=TRUE." – srb633 Apr 03 '20 at 08:48
  • Columns are connected through `cbind`. `rbind` adds rows to the data. – nya Apr 03 '20 at 08:49
  • Haha okay sweet, that did it. Thank you – srb633 Apr 03 '20 at 08:52

1 Answers1

1

Maybe you can try the code below if you would like to use rbind

do.call(rbind,Map(as.matrix,data))

Example

df1 <- data.frame(a = 1:2, b = 1:2)
df2 <- data.frame(c = 1:3, d = 1:3)
data <- list(df1,df2)

such that

> do.call(rbind,Map(as.matrix,data))
     a b
[1,] 1 1
[2,] 2 2
[3,] 1 1
[4,] 2 2
[5,] 3 3
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81