View source: R/data_relocate.R
| data_relocate | R Documentation |
data_relocate() will reorder columns to specific positions, indicated by
before or after. data_reorder() will instead move selected columns to
the beginning of a data frame. Finally, data_remove() removes columns
from a data frame. All functions support select-helpers that allow flexible
specification of a search pattern to find matching columns, which should
be reordered or removed.
data_relocate(
data,
select,
before = NULL,
after = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...
)
data_reorder(
data,
select,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...
)
data_remove(
data,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = FALSE,
...
)
data |
A data frame. |
select |
Variables that will be included when performing the required tasks. Can be either
If |
before, after |
Destination of columns. Supplying neither will move
columns to the left-hand side; specifying both is an error. Can be a
character vector, indicating the name of the destination column, or a
numeric value, indicating the index number of the destination column.
If |
ignore_case |
Logical, if |
regex |
Logical, if |
verbose |
Toggle warnings. |
... |
Arguments passed down to other functions. Mostly not used yet. |
exclude |
See |
A data frame with reordered columns.
Add a prefix or suffix to column names: data_addprefix(), data_addsuffix()
Functions to reorder or remove columns: data_reorder(), data_relocate(),
data_remove()
Functions to reshape, pivot or rotate data frames: data_to_long(),
data_to_wide(), data_rotate()
Functions to recode data: rescale(), reverse(), categorize(),
recode_values(), slide()
Functions to standardize, normalize, rank-transform: center(), standardize(),
normalize(), ranktransform(), winsorize()
Split and merge data frames: data_partition(), data_merge()
Functions to find or select columns: data_select(), extract_column_names()
Functions to filter rows: data_match(), data_filter()
# Reorder columns
head(data_relocate(iris, select = "Species", before = "Sepal.Length"))
head(data_relocate(iris, select = "Species", before = "Sepal.Width"))
head(data_relocate(iris, select = "Sepal.Width", after = "Species"))
# which is same as
head(data_relocate(iris, select = "Sepal.Width", after = -1))
# Reorder multiple columns
head(data_relocate(iris, select = c("Species", "Petal.Length"), after = "Sepal.Width"))
# which is same as
head(data_relocate(iris, select = c("Species", "Petal.Length"), after = 2))
# Reorder columns
head(data_reorder(iris, c("Species", "Sepal.Length")))
# Remove columns
head(data_remove(iris, "Sepal.Length"))
head(data_remove(iris, starts_with("Sepal")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.