EVOLUTION-MANAGER
Edit File: relocate.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: Change column order</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 relocate {dplyr}"><tr><td>relocate {dplyr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Change column order</h2> <h3>Description</h3> <p>Use <code>relocate()</code> to change column positions, using the same syntax as <code>select()</code> to make it easy to move blocks of columns at once. </p> <h3>Usage</h3> <pre> relocate(.data, ..., .before = NULL, .after = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>.data</code></td> <td> <p>A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See <em>Methods</em>, below, for more details.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p><<code><a href="dplyr_tidy_select.html">tidy-select</a></code>> Columns to move.</p> </td></tr> <tr valign="top"><td><code>.before, .after</code></td> <td> <p><<code><a href="dplyr_tidy_select.html">tidy-select</a></code>> Destination of columns selected by <code>...</code>. Supplying neither will move columns to the left-hand side; specifying both is an error.</p> </td></tr> </table> <h3>Value</h3> <p>An object of the same type as <code>.data</code>. The output has the following properties: </p> <ul> <li><p> Rows are not affected. </p> </li> <li><p> The same columns appear in the output, but (usually) in a different place. </p> </li> <li><p> Data frame attributes are preserved. </p> </li> <li><p> Groups are not affected. </p> </li></ul> <h3>Methods</h3> <p>This function is a <strong>generic</strong>, which means that packages can provide implementations (methods) for other classes. See the documentation of individual methods for extra arguments and differences in behaviour. </p> <p>The following methods are currently available in loaded packages: no methods found. </p> <h3>Examples</h3> <pre> df <- tibble(a = 1, b = 1, c = 1, d = "a", e = "a", f = "a") df %>% relocate(f) df %>% relocate(a, .after = c) df %>% relocate(f, .before = b) df %>% relocate(a, .after = last_col()) # Can also select variables based on their type df %>% relocate(where(is.character)) df %>% relocate(where(is.numeric), .after = last_col()) # Or with any other select helper df %>% relocate(any_of(c("a", "e", "i", "o", "u"))) # When .before or .after refers to multiple variables they will be # moved to be immediately before/after the selected variables. df2 <- tibble(a = 1, b = "a", c = 1, d = "a") df2 %>% relocate(where(is.numeric), .after = where(is.character)) df2 %>% relocate(where(is.numeric), .before = where(is.character)) </pre> <hr /><div style="text-align: center;">[Package <em>dplyr</em> version 1.0.2 <a href="00Index.html">Index</a>]</div> </body></html>