move.column.after: Move a column in a data frame after a specified column.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/moving.R

Description

This function moves a given column or a vector of columns behind a specific position in the data frame. Columns are specified by their names.

Usage

1
move.column.after(df, col.name, col.name.after)

Arguments

df

data frame

col.name

column name or vector of column names to move

col.name.after

column name behind which to place col.name ("first" to place at beginning)

Value

Data frame with rearranged columns.

Author(s)

Pascal Benkert

See Also

move.column.to.pos

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## create a dataframe
a_dataframe <- data.frame(a=c(1,0),b=c(2,0),c=c(3,0),d=c(4,0))
a_dataframe
##   a b c d
## 1 1 2 3 4
## 2 0 0 0 0

## move columns c and d behind column a
move.column.after(df=a_dataframe,col.name=c("c","d"),col.name.after="a")
##   a c d b
## 1 1 3 4 2
## 2 0 0 0 0

SwissClinicalTrialOrganisation/DM_secuTrial_R documentation built on May 21, 2019, 10:16 a.m.