Recode number or strings
Recode discrete variables, including numerice and character variable.
rec_num(x, rec, keep = TRUE) rec_char(x, rec, keep = TRUE)
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 |
A vector.
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.