shuffle: Move the Columns of a Data Frame Relative to Each Other

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

It can be tedious to reorder the columns in a data.frame. This function lets you move specific columns relative to some other named column.

Usage

1
shuffle(x, who, after = NA)

Arguments

x

data.frame

who

a character vector of column names to move, or a logical vector of length names(x), or a vector of indices

after

the column after which to put who: may be character, integer, NA, or NULL

Details

If after is NA, the named columns are moved to the front (before the first column). If after has length zero, or is a number less than zero or an integer greater than the number of remaining columns, or is NULL, who is moved to the end. If an integer less than or equal to the number of remaining columns, who is placed after the corresponding column.

Value

data.frame: a variant of x

Note

As of 5.56, duplicate column names are resolved by make.unique without warning.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

1
2
3
4
head(Theoph)
head(shuffle(Theoph,'Time'))
names(Theoph) <- c('Subject','Wt', 'Dose', 'Time',  'Time')
head(shuffle(Theoph,'Time'))

metrumrg documentation built on May 2, 2019, 5:55 p.m.