f_parenthesis {numform} | R Documentation |
Parenthesis Formatting of Two Vectors
Description
f_parenthesis
- Form two vectors of numbers as a leading number
followed by a second number in parenthesis.
f_mean_sd
- Wrapper for f_parenthesis
optimized for formatting
vectors of means and standard deviations.
f_num_percent
- Wrapper for f_parenthesis
optimized for formatting
vectors of numbers and percentages deviations.
Usage
f_parenthesis(x, y, sep = "", x_prefix = "", y_prefix = "", ...)
ff_parenthesis(...)
f_mean_sd(x, y, x_digits = 1, y_digits = x_digits, sep = "", ...)
ff_mean_sd(...)
f_num_percent(
x,
y,
x_digits = 1,
y_digits = x_digits,
sep = "",
prop_fun = numform::f_prop2percent,
...
)
ff_num_percent(...)
Arguments
x |
Vector 1 (in |
y |
Vector 2 (in |
sep |
The separator between the first number and the leading parenthesis. |
x_prefix |
A constant to place before each value in the x vector. |
y_prefix |
A constant to place before each value in the y vector inside of the parenthesis. |
x_digits |
The number of digits to round the x vector. |
y_digits |
The number of digits to round the y vector. |
prop_fun |
The proportion function to convert the y y vector in
|
... |
ignored. |
Value
Returns a vector of parenthesis combined strings using vector x and y.
Examples
f_parenthesis(
f_num(sample(50:100, 5), 1),
f_num(rnorm(5, 5:15, 5), 1),
prefix = 'mean = ',
parenthesis_prefix = 'sd = ',
sep = " "
)
f_mean_sd(rnorm(5, 100, 20), rnorm(5, 20, 5))
f_num_percent(rnorm(5, 100, 20), rnorm(5, .5, .1))
f_parenthesis(
sample(50:100, 5),
f_prop2percent(rnorm(5, .5, .1), 0)
)
## Not run:
library(tidyverse)
mtcars %>%
group_by(cyl) %>%
summarize(
mean = mean(hp),
sd = sd(hp),
n = n()
) %>%
mutate(
prop = n /sum(n),
mean_sd = f_mean_sd(mean, sd),
n_perc = f_num_percent(n, prop, 0)
)
## End(Not run)