fac.uselogical {dae}R Documentation

Forms a two-level 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"), ...)



A logical vector with values TRUE or FALSE. If the vector is not a logical, as.logical will be used in an attempt to coerce it to logical.


A vector of length two with values TRUE or T and FALSE or F, in either order depending on which of TRUE or FALSE is to be the first level.


A vector of length two with values to be used as labels for the first and second levels, respectively.


Further arguments passed to the factor call creating the new factor.


A factor.


Chris Brien

See Also

fac.recode, 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")

[Package dae version 3.2-13 Index]