fac.uselogical {dae} | R Documentation |
Forms a two-level factor
from a logical
object.
Description
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
.
Usage
fac.uselogical(x, levels = c(TRUE, FALSE), labels = c("yes", "no"), ...)
Arguments
x |
A |
levels |
A |
labels |
A |
... |
Further arguments passed to the |
Value
A factor
.
Author(s)
Chris Brien
See Also
fac.recast
, as.numfac
and mpone
in package dae,
factor
, relevel
.
Examples
## 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")
[Package dae version 3.2.28 Index]