rec {tidyfst} | R Documentation |
Recode number or strings
Description
Recode discrete variables, including numerice and character variable.
Usage
rec_num(x, rec, keep = TRUE)
rec_char(x, rec, keep = TRUE)
Arguments
x |
A numeric or character vector. |
rec |
String with recode pairs of old and new values. Find the usage in examples. |
keep |
Logical. Decide whether to keep the original values if not recoded.
Defaults to |
Value
A vector.
See Also
Examples
x = 1:10
x
rec_num(x, rec = "1=10; 4=2")
rec_num(x, rec = "1:3=1; 4:6=2")
rec_num(x, rec = "1:3=1; 4:6=2",keep = FALSE)
y = letters[1:5]
y
rec_char(y,rec = "a=A;b=B")
rec_char(y,rec = "a,b=A;c,d=B")
rec_char(y,rec = "a,b=A;c,d=B",keep = FALSE)
[Package tidyfst version 1.7.9 Index]