recode | R Documentation |
Converts a specified value to another value.
recode(x, from, to) ## S3 method for class 'factor' recode(x, from, to) ## S3 method for class 'integer' recode(x, from, to) ## S3 method for class 'character' recode(x, from, to) ## S3 method for class 'numeric' recode(x, from, to)
x |
a vector. Missing values ( |
from |
the target value to match and replace. |
to |
the replacement value. |
An object like vector with each target value replaced by the specified value.
When used on numeric (type "double"), the recode
function uses an approximate match within a small tolerance range to avoid
mismatches due to computations.
The function sub
offers greater
flexibility than recode
for replacing parts of text instead of the
complete text.
sub
, na2miss
, miss2na
XT <- c(1, 2, 0, 4) recode(XT, 0, 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.