move.column.to.pos: Move a column in a data frame by index.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/moving.R

Description

This function moves a given column (defined by the column index) to a specific position in the data frame.

Usage

1
move.column.to.pos(df, col.idx, new.col.idx)

Arguments

df

data frame

col.idx

old column index

new.col.idx

new column index

Value

Data frame with rearranged columns.

Author(s)

Pascal Benkert

See Also

move.column.after

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 column 1 to column 3
move.column.to.pos(df=a_dataframe,col.idx=1,new.col.idx=3)
##   b c a d
## 1 2 3 1 4
## 2 0 0 0 0

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