0

I am trying to combine all my rds results into one data frame.

right now, I have the following:

  1: data.table[37x16]
  2: data.table[37x16]
  3: data.table[37x16]
  4: data.table[37x16]
  5: data.table[37x16]       
212: data.table[37x16]
213: data.table[37x16]
214: data.table[37x16]
215: data.table[37x16]
216: data.table[37x16]

V1 is a list of 216.

each data. table inside the list has the same variables, and I am trying to make it into one data. table.

Do you have any ideas?

Aolin Gong
  • 11
  • 1

1 Answers1

0

You could try using bind_rows from dplyr, which combines by row.

Here's an example.

df1 <- tibble(x=1:3, y=4:6)

# A tibble: 3 x 2
      x     y
  <int> <int>
1     1     4
2     2     5
3     3     6
df2 <- tibble(x=7:9, y=9:11)

# A tibble: 3 x 2
      x     y
  <int> <int>
1     7     9
2     8    10
3     9    11
bind_rows(df1, df2)

# A tibble: 6 x 2
      x     y
  <int> <int>
1     1     4
2     2     5
3     3     6
4     7     9
5     8    10
6     9    11

Since you have many data frames, you can put them in a list and then use bind_rows.

l <- list(df1, df2)

bind_rows(l)

# A tibble: 6 x 2
      x     y
  <int> <int>
1     1     4
2     2     5
3     3     6
4     7     9
5     8    10
6     9    11
max
  • 4,141
  • 5
  • 26
  • 55