put.first: Simple way to put certain cols first, in a data.frame

View source: R/put.first.R

put.firstR Documentation

Simple way to put certain cols first, in a data.frame

Description

Returns a data.frame with specified columns put first, before the others.

Usage

put.first(x, fields)

Arguments

x

Required data.frame that will have its columns reordered

fields

required character vector of strings that are among the elements of names(x)

Value

Returns a transformed data.frame with cols in new order

Examples

before <- data.frame(year=c(2,2,2), ID=3, numbers=4, last=1)
put.first(before, c('ID', 'numbers'))
after <- put.first(before, names(before)[length(before)] ) # put last column first
before; after

ejanalysis/countyhealthrankings documentation built on March 25, 2022, 9:15 a.m.