Description Usage Arguments Details Examples
Recode variables
1 |
x |
numeric or character vector with values to recode. |
... |
recode pairs in the format |
default |
numeric or character. All entries in |
coerce |
a function that is applied to |
The left hand side of the recode pairs in ...
can be one of:
e.g. "CTX" = "Context"
, "3" = 5
e.g. "1:10" = 5
, "6:10" = "above
five"
e.g. "c('A', 'B')" = "AB"
(note the use of
single quotes inside the double quotes)
e.g. "< 20" = "small"
, "<= 10 | > 90"
= "outlier"
, "> 40 & < 60" = "normal"
1 2 3 4 5 6 7 8 9 | recode(c("female", "male", "male", "female"), "female" = "f", "male" = "m")
recode(1:10, "1:5" = "a", "6:10" = "b")
recode(1:20, "1:10" = 5, "11:20" = 15)
recode(1:20, "< 3" = "small", ">= 3 & <= 8" = "medium", "> 8" = "large")
recode(sample(letters[1:6]), "c('a', 'b', 'c')" = "abc",
"c('d', 'e', 'f')" = "def")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.