Efficiently bind multiple data frames by row and column.

This is an efficient implementation of the common pattern of do.call(rbind, dfs) or do.call{cbind, dfs} for binding many data frames into one. combine() acts like c() or unlist() but uses consistent dplyr coercion rules.


bind_rows(x, ...)

bind_cols(x, ...)

combine(x, ...)


Data frames to combine.

You can either supply one data frame per argument, or a list of data frames in the first argument.

When column-binding, rows are matched by position, not value so all data frames must have the same number of rows. To match by value, not position, see left_join etc. When row-binding, columns are matched by name, and any values that don't match will be filled with NA.


bind_rows and bind_cols always return a tbl_df

Deprecated functions

rbind_list and rbind_all have been deprecated. Instead use bind_rows.

  • bind
  • bind_cols
  • bind_rows
  • combine
  • rbind_all
  • rbind_list
one <- mtcars[1:4, ]
two <- mtcars[11:14, ]

# You can either supply data frames as arguments
bind_rows(one, two)
# Or a single argument containing a list of data frames
bind_rows(list(one, two))
bind_rows(split(mtcars, mtcars$cyl))

# Columns don't need to match when row-binding
bind_rows(data.frame(x = 1:3), data.frame(y = 1:4))
## Not run: ------------------------------------
# # Rows do need to match when column-binding
# bind_cols(data.frame(x = 1), data.frame(y = 1:2))
## ---------------------------------------------

bind_cols(one, two)
bind_cols(list(one, two))

# combine applies the same coercion rules
f1 <- factor("a")
f2 <- factor("b")
c(f1, f2)
unlist(list(f1, f2))

combine(f1, f2)
combine(list(f1, f2))
Documentation reproduced from package dplyr, version, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.