Learn R Programming

useful (version 1.2.6.1)

shift.column: shift.column

Description

Shift a column of data

Usage

shift.column(data, columns, newNames = sprintf("%s.Shifted", columns),
  len = 1L, up = TRUE)

Value

data.frame with the specified columns shifted.

Arguments

data

data.frame

columns

Character vector specifying which columns to shift.

newNames

Character vector specifying new names for the columns that will be created by the shift. Must be same length as columns.

len

Integer specifying how many rows to shift the data.

up

logical indicating if rows should be shifted up or down.

Author

Jared P. Lander

Details

Shifts a column of data up or down a certain number of rows

Examples

Run this code

myData <- data.frame(Upper=LETTERS, lower=letters)
shift.column(data=myData, columns="lower")
shift.column(data=myData, columns="lower", len=2)

Run the code above in your browser using DataLab