cpcol: Copy columns in a data frame.

cpcolR Documentation

Copy columns in a data frame.

Description

cpcol copies columns in a data frame.

Usage

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

Arguments

d

data frame

on

original column name (or part of it, or a regexpr)

nn

desired column name (or part of it, 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

rencol

Examples

tmp<-data.frame(a=1:2,b=2:3)
cpcol(tmp,'a','a2')
# copy with explicit column idx check
cpcol(tmp,'a','a2',1)

# copy all columns starting with 'a.' as 'b.'
tmp<-data.frame(a.x=1:2,a.b=2:3)
cpcol(tmp,'a.','b.',multi=TRUE)

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