df.move {misty} | R Documentation |
Move Variable(s) in a Data Frame
Description
This function moves variables to a different position in the data frame, i.e.,
changes the column positions in the data frame. By default, variables specified
in the first argument ...
are moved to the first position in the data
frame specified in the argument data
.
Usage
df.move(..., data = NULL, before = NULL, after = NULL, first = TRUE, check = FALSE)
Arguments
... |
an expression indicating the variable names in |
data |
a data frame. |
before |
a character string indicating a variable in |
after |
a character string indicating a variable in |
first |
logical: if |
check |
logical: if |
Value
Returns the data frame in data
with columns in a different place.
Author(s)
Takuya Yanagida takuya.yanagida@univie.ac.at
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
See Also
df.duplicated
, df.merge
,
df.rbind
,
df.rename
, df.sort
,
df.subset
Examples
# Example 1: Move variables 'hp' and 'am' to the first position
df.move(hp, am, data = mtcars)
# Example 2: Move variables 'hp' and 'am' to the last position
df.move(hp, am, data = mtcars, first = FALSE)
# Example 3: Move variables 'hp' and 'am' to the left-hand side of 'disp'
df.move(hp, am, data = mtcars, before = "disp")
# Example 4: Move variables 'hp' and 'am' to the right-hand side of 'disp'
df.move(hp, am, data = mtcars, after = "disp")