f_affirm {numform} | R Documentation |
Yes/No Convert Logical/Dummy Code
Description
Coerce logical (TRUE
, FALSE
) or or dummy coded elements (0/1)
to "Yes"/"No" elements. This function is most useful in plot scales.
Usage
f_affirm(x, true = "Yes", false = "No", ...)
ff_affirm(...)
Arguments
x |
A vector of logical or dummy integers. This vector will be coerced to logical. |
true |
A value for |
false |
A value for |
... |
ignored. |
Value
Returns a string of either "Yes" or "No" elements.
See Also
Examples
f_affirm(c(TRUE, TRUE, FALSE))
f_affirm(c(1, 1, 0, 1, 0, 0, NA))
f_affirm(c(1, 0, 2, .3, -3))
f_affirm(rnorm(20) > 0)
f_affirm(rnorm(20) > 0, "A", "B")
## Not run:
library(ggplot2)
library(dplyr)
## Without labels
data_frame(dummy = sample(c(TRUE, FALSE), 30, TRUE)) %>%
count(dummy) %>%
ggplot(aes(dummy, n)) +
geom_bar(stat = 'identity')
## With labels
data_frame(dummy = sample(c(TRUE, FALSE), 30, TRUE)) %>%
count(dummy) %>%
ggplot(aes(dummy, n)) +
geom_bar(stat = 'identity') +
scale_x_discrete(labels = f_affirm)
## End(Not run)
[Package numform version 0.7.0 Index]