Description Usage Arguments Value Author(s) See Also Examples
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.
1 | move.column.after(df, col.name, col.name.after)
|
df |
data frame |
col.name |
column name or vector of column names to move |
col.name.after |
column name behind which to place |
Data frame with rearranged columns.
Pascal Benkert
move.column.to.pos
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.