Learn R Programming

DataCombine (version 0.1.3)

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

Description

MoveFront moves a specified variable to the front of a data frame.

Usage

MoveFront(data, Var)

Arguments

data
a data frame object containing the variable you want to move.
Var
a character string naming the variable you would like to move to the front of the data frame.

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
NewOrder <- MoveFront(OldOrder, "C")
names(NewOrder)

Run the code above in your browser using DataLab