Description Usage Arguments Value Author(s) See Also Examples
This function moves a given column (defined by the column index) to a specific position in the data frame.
1 | move.column.to.pos(df, col.idx, new.col.idx)
|
df |
data frame |
col.idx |
old column index |
new.col.idx |
new column index |
Data frame with rearranged columns.
Pascal Benkert
move.column.after
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.