Description Usage Arguments Details Value Author(s) References Examples
This function takes a vector object as input, and encodes (or re-encodes, as appropriate) the vector as a factor with levels corresponding to newlevels, a list object.
1 |
x |
A vector. |
newlevels |
A list of levels to use for refactoring, named according to the original levels of |
includeNA |
Boolean; should |
This is merely a convenience function to simplify renaming and collapsing factor levels. Original
code written by Marek Szatkowski – only difference here is slight change to handle NA
values.
The functions returns x
, with levels collapsed/renamed according to newlevels
.
Marek Szatkowski
1 2 3 4 5 6 7 8 9 10 | ## Not run:
test$tpt <- refactor(test$tpt, list("1-2hr Post-dose"=c("1-2 HOUR POST DOS",
"1-2 HOUR POST DOSE", "1-2 HR POSTDOSE", "1 HOUR POST DOSE"), "6-10hr Post-dose"="6-10 HOUR POST DOSE"))
# To include NA as a factor level and reclassify:
test$tpt <- refactor(test$tpt, list("1-2hr Post-dose"=c("1-2 HOUR POST DOS", "1-2 HOUR POST DOSE",
"1-2 HR POSTDOSE", "1 HOUR POST DOSE"), "6-10hr Post-dose"="6-10 HOUR POST DOSE", "Pre-dose"=NA), includeNA=TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.