Rename {epicalc}R Documentation

Rename variable(s) in the default data frame

Description

Rename a variable or change a pattern of variable names.

Usage

rename(x1, x2, dataFrame = .data, ...)

## Default S3 method:
rename(x1, x2, dataFrame = .data, ...)

## S3 method for class 'var':
rename(x1, x2, dataFrame = .data, ...)

## S3 method for class 'pattern':
rename(x1, x2, dataFrame = .data, printNote=TRUE, ...)

ren(x1, x2, dataFrame = .data, ...)

Arguments

x1 a variable or a pattern among the names of the variables inside .data.
x2 new name or new pattern of the variable(s).

FUNCTION 'x1' 'x2'
'rename.var' old variable new variable
'rename.pattern' old pattern new pattern

dataFrame a data frame, the variable(s) of which will be renamed
printNote whether the table of old names and new names of the variables(s) should be printed out.
... further arguments passed to or used by other methods.

Details

'rename.var' renames variable 'x1' to 'x2'. Both arguments may have the quotes omitted.

'rename.pattern' changes substring 'x1' in any names of variables inside .data to 'x2'. With 'printNote=TRUE', a table with columns of old and new variables will be displayed.

'rename.var' is called if 'x1' perfectly matches with a variable name. 'rename.pattern' is called if the pattern 'x1' is found as a substring among the variable names. Otherwise, an error will occur.

Finally, 'ren' is the abbreviated form of 'rename' without any suffix

Author(s)

Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

See Also

'recode' and 'label.var'

Examples

data(Oswego)
use(Oswego)
des()
rename.var("ill", "sick")
des()
# Note change of the 4th variable name

rename(timesupper, time.of.supper) 
# Note that '.var' and the quotes '"' can be omitted.
# But not 'rename(timesupper, "time of supper")'. Why? 

# Even shorter with 'ren'
ren(sex, gender)
des()

rename.pattern("ll", "LL")  
des()
rename("onset", "onset_") 
# '.pattern' can be omitted but not the quotes.
des()

[Package epicalc version 2.10.1.1 Index]