EVOLUTION-MANAGER
Edit File: data_frame.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: Construct a data frame</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 data_frame {vctrs}"><tr><td>data_frame {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Construct a data frame</h2> <h3>Description</h3> <p><code>data_frame()</code> constructs a data frame. It is similar to <code><a href="../../base/html/data.frame.html">base::data.frame()</a></code>, but there are a few notable differences that make it more in line with vctrs principles. The Properties section outlines these. </p> <h3>Usage</h3> <pre> data_frame( ..., .size = NULL, .name_repair = c("check_unique", "unique", "universal", "minimal", "unique_quiet", "universal_quiet"), .error_call = current_env() ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Vectors to become columns in the data frame. When inputs are named, those names are used for column names.</p> </td></tr> <tr valign="top"><td><code>.size</code></td> <td> <p>The number of rows in the data frame. If <code>NULL</code>, this will be computed as the common size of the inputs.</p> </td></tr> <tr valign="top"><td><code>.name_repair</code></td> <td> <p>One of <code>"check_unique"</code>, <code>"unique"</code>, <code>"universal"</code>, <code>"minimal"</code>, <code>"unique_quiet"</code>, or <code>"universal_quiet"</code>. See <code><a href="vec_as_names.html">vec_as_names()</a></code> for the meaning of these options.</p> </td></tr> <tr valign="top"><td><code>.error_call</code></td> <td> <p>The execution environment of a currently running function, e.g. <code>caller_env()</code>. The function will be mentioned in error messages as the source of the error. See the <code>call</code> argument of <code><a href="../../rlang/html/abort.html">abort()</a></code> for more information.</p> </td></tr> </table> <h3>Details</h3> <p>If no column names are supplied, <code>""</code> will be used as a default name for all columns. This is applied before name repair occurs, so the default name repair of <code>"check_unique"</code> will error if any unnamed inputs are supplied and <code>"unique"</code> (or <code>"unique_quiet"</code>) will repair the empty string column names appropriately. If the column names don't matter, use a <code>"minimal"</code> name repair for convenience and performance. </p> <h3>Properties</h3> <ul> <li><p> Inputs are <a href="vector_recycling_rules.html">recycled</a> to a common size with <code><a href="vec_recycle.html">vec_recycle_common()</a></code>. </p> </li> <li><p> With the exception of data frames, inputs are not modified in any way. Character vectors are never converted to factors, and lists are stored as-is for easy creation of list-columns. </p> </li> <li><p> Unnamed data frame inputs are automatically unpacked. Named data frame inputs are stored unmodified as data frame columns. </p> </li> <li> <p><code>NULL</code> inputs are completely ignored. </p> </li> <li><p> The dots are dynamic, allowing for splicing of lists with <code style="white-space: pre;">!!!</code> and unquoting. </p> </li></ul> <h3>See Also</h3> <p><code><a href="df_list.html">df_list()</a></code> for safely creating a data frame's underlying data structure from individual columns. <code><a href="new_data_frame.html">new_data_frame()</a></code> for constructing the actual data frame from that underlying data structure. Together, these can be useful for developers when creating new data frame subclasses supporting standard evaluation. </p> <h3>Examples</h3> <pre> data_frame(x = 1, y = 2) # Inputs are recycled using tidyverse recycling rules data_frame(x = 1, y = 1:3) # Strings are never converted to factors class(data_frame(x = "foo")$x) # List columns can be easily created df <- data_frame(x = list(1:2, 2, 3:4), y = 3:1) # However, the base print method is suboptimal for displaying them, # so it is recommended to convert them to tibble if (rlang::is_installed("tibble")) { tibble::as_tibble(df) } # Named data frame inputs create data frame columns df <- data_frame(x = data_frame(y = 1:2, z = "a")) # The `x` column itself is another data frame df$x # Again, it is recommended to convert these to tibbles for a better # print method if (rlang::is_installed("tibble")) { tibble::as_tibble(df) } # Unnamed data frame input is automatically unpacked data_frame(x = 1, data_frame(y = 1:2, z = "a")) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>