Learn R Programming

DataCombine (version 0.1.11)

MoveFront: Move variables to the front of a data frame.

Description

MoveFront moves variables to the front of a data frame.

Usage

MoveFront(data, Var)

Arguments

source

Based on a Stack Overflow answer written by rcs:

Examples

Run this code
# Create dummy data
A <- B <- C <- 1:50
OldOrder <- data.frame(A, B, C)

# Move C to front
NewOrder1 <- MoveFront(OldOrder, "C")
names(NewOrder1)

# Move B and A to the front
NewOrder2 <- MoveFront(OldOrder, c("B", "A"))
names(NewOrder2)

Run the code above in your browser using DataLab