fac.uselogical | R Documentation |
factor
from a logical
object.Forms a two-level factor
from a logical
object.
It can be used to recode a factor
when the resulting factor
is to have only two levels
.
fac.uselogical(x, levels = c(TRUE, FALSE), labels = c("yes", "no"), ...)
x |
A |
levels |
A |
labels |
A |
... |
Further arguments passed to the |
A factor
.
Chris Brien
fac.recast
, as.numfac
and mpone
in package dae,
factor
, relevel
.
## set up a factor with labels
Treats <- factor(rep(1:4, 4), labels=c("A","B","C","D"))
## recode "A" and "D" to "a" and "B" and "C" to "b"
B <- fac.uselogical(Treats %in% c("A", "D"), labels = c("a","b"))
B <- fac.uselogical(Treats %in% c("A", "D"), labels = c(-1,1))
## suppose level A in factor a is a control treatment
## set up a factor Control to discriminate between control and treated
Control <- fac.uselogical(Treats == "A")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.