renameCol: Rename columns in a matrix or a dataframe.

Description Usage Arguments Value Author(s) Examples

View source: R/renameCol.R

Description

Rename columns in a matrix or a dataframe.

Usage

1
renameCol(indata, src, tgt)

Arguments

indata

A dataframe or a matrix

src

Source: Vector of names of columns in 'indata' to be renamed. Can also be a vector of column numbers.

tgt

Target: Vector with corresponding new names in the output.

Value

A dataframe if 'indata' is a dataframe; a matrix in 'indata' is a matrix.

Author(s)

Søren Højsgaard, [email protected]

Examples

1
2
3
4
5
6
renameCol(CO2, 1:2, c("kk", "ll"))
renameCol(CO2, c("Plant", "Type"), c("kk", "ll"))

# These fail - as they should:
# renameCol(CO2, c("Plant", "Type", "conc"), c("kk", "ll"))
# renameCol(CO2, c("Plant", "Type", "Plant"), c("kk", "ll"))

doBy documentation built on Aug. 30, 2018, 9:03 a.m.