f_logical: True/False Convert Logical/Dummy Code

Description Usage Arguments Value See Also Examples

View source: R/f_logical.R

Description

Coerce logical (TRUE, FALSE) or or dummy coded elements (0/1) to "True"/"False" elements. This function is most useful in plot scales.

Usage

1
2
3
4
5
6
7
f_logical(x, true = "True", false = "False", ...)

ff_logical(...)

f_response(x, yes = "Yes", no = "No", ...)

ff_response(...)

Arguments

x

A vector of logical or dummy integers. This vector will be coerced to logical.

true

A value for TRUE elements.

false

A value for FALSE elements.

yes

A value for TRUE elements.

no

A value for FALSE elements.

...

ignored.

Value

Returns a string of either "True"/"False" elements.

See Also

prettyNum

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
f_logical(c(TRUE, TRUE, FALSE))
f_logical(c(1, 1, 0, 1, 0, 0, NA))
f_logical(c(1, 0, 2, .3, -3))
f_logical(rnorm(20) > 0)
f_logical(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_logical)

## End(Not run)

numform documentation built on Oct. 10, 2021, 1:10 a.m.