rencol: Rename columns in a data frame.

rencolR Documentation

Rename columns in a data frame.

Description

rencol renames columns in a data frame.

Usage

rencol(d, on, nn, i = NULL, 
    regexp = FALSE, multi = FALSE)

Arguments

d

data frame

on

original column name (or a regexpr)

nn

desired column name (or a regexpr)

i

optional column index that must match the column with the name denoted by on (this serves as a sanity check ensuring the change affects the intended column)

regexp

logical flag indicating whether on and nn contain regular expressions

multi

logical flag indicating whether to change multiple coumns at once

Author(s)

Tomas Sieger

See Also

cpcol

Examples

tmp<-data.frame(a=1:2,b=2:3)
rencol(tmp,'a','a2')
rencol(tmp,'a','a2',1)

# get rid of a common prefix
tmp<-data.frame(prefix.a=1:2,prefix.b=2:3)
rencol(tmp,'prefix.','',multi=TRUE)

tsieger/tsiMisc documentation built on Oct. 10, 2023, 10:24 p.m.