shift.column: shift.column

View source: R/shiftColumn.r

shift.columnR Documentation

shift.column

Description

Shift a column of data

Usage

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

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.

Details

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

Value

data.frame with the specified columns shifted.

Author(s)

Jared P. Lander

Examples


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


jaredlander/useful documentation built on Nov. 4, 2023, 10:56 a.m.