rec | R Documentation |
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.
rec
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.