EVOLUTION-MANAGER
Edit File: bind.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Efficiently bind multiple data frames by row and column</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for bind {dplyr}"><tr><td>bind {dplyr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Efficiently bind multiple data frames by row and column</h2> <h3>Description</h3> <p>This is an efficient implementation of the common pattern of <code>do.call(rbind, dfs)</code> or <code>do.call(cbind, dfs)</code> for binding many data frames into one. </p> <h3>Usage</h3> <pre> bind_rows(..., .id = NULL) bind_cols( ..., .name_repair = c("unique", "universal", "check_unique", "minimal") ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Data frames to combine. </p> <p>Each argument can either be a data frame, a list that could be a data frame, or a list of data frames. </p> <p>When row-binding, columns are matched by name, and any missing columns will be filled with NA. </p> <p>When column-binding, rows are matched by position, so all data frames must have the same number of rows. To match by value, not position, see <a href="mutate-joins.html">mutate-joins</a>.</p> </td></tr> <tr valign="top"><td><code>.id</code></td> <td> <p>Data frame identifier. </p> <p>When <code>.id</code> is supplied, a new column of identifiers is created to link each row to its original data frame. The labels are taken from the named arguments to <code>bind_rows()</code>. When a list of data frames is supplied, the labels are taken from the names of the list. If no names are found a numeric sequence is used instead.</p> </td></tr> <tr valign="top"><td><code>.name_repair</code></td> <td> <p>One of <code>"unique"</code>, <code>"universal"</code>, or <code>"check_unique"</code>. See <code><a href="../../vctrs/html/vec_as_names.html">vctrs::vec_as_names()</a></code> for the meaning of these options.</p> </td></tr> </table> <h3>Details</h3> <p>The output of <code>bind_rows()</code> will contain a column if that column appears in any of the inputs. </p> <h3>Value</h3> <p><code>bind_rows()</code> and <code>bind_cols()</code> return the same type as the first input, either a data frame, <code>tbl_df</code>, or <code>grouped_df</code>. </p> <h3>Examples</h3> <pre> one <- starwars[1:4, ] two <- starwars[9:12, ] # You can supply data frames as arguments: bind_rows(one, two) # The contents of lists are spliced automatically: bind_rows(list(one, two)) bind_rows(split(starwars, starwars$homeworld)) bind_rows(list(one, two), list(two, one)) # In addition to data frames, you can supply vectors. In the rows # direction, the vectors represent rows and should have inner # names: bind_rows( c(a = 1, b = 2), c(a = 3, b = 4) ) # You can mix vectors and data frames: bind_rows( c(a = 1, b = 2), tibble(a = 3:4, b = 5:6), c(a = 7, b = 8) ) # When you supply a column name with the `.id` argument, a new # column is created to link each row to its original data frame bind_rows(list(one, two), .id = "id") bind_rows(list(a = one, b = two), .id = "id") bind_rows("group 1" = one, "group 2" = two, .id = "groups") # Columns don't need to match when row-binding bind_rows(tibble(x = 1:3), tibble(y = 1:4)) ## Not run: # Rows do need to match when column-binding bind_cols(tibble(x = 1:3), tibble(y = 1:2)) # even with 0 columns bind_cols(tibble(x = 1:3), tibble()) ## End(Not run) bind_cols(one, two) bind_cols(list(one, two)) </pre> <hr /><div style="text-align: center;">[Package <em>dplyr</em> version 1.0.2 <a href="00Index.html">Index</a>]</div> </body></html>