| Rename {epicalc} | R Documentation |
Renaming a variable or change a pattern of variable names.
rename(x1, x2, ...) ## Default S3 method: rename(x1, x2, ...) ## S3 method for class 'var': rename(x1, x2, ...) ## S3 method for class 'pattern': rename(x1, x2, printNote=TRUE, ...) ren(x1, x2, ...)
x1 |
a variable or a pattern among the names of the variables inside .data. | ||||||||||||
x2 |
new name or new pattern of the variable(s).
| ||||||||||||
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 methods. |
'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.
The suffixes of 'rename' viz '.var' and '.pattern' can be omitted. 'rename.var' is called if 'x1' perfectly matches with a variable name. Instead, 'rename.pattern' is called if the pattern 'x2' 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
Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>
'recode' and 'label.var'
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()