table_glue {table.glue} | R Documentation |
Expressive rounding for table values
Description
Expressive rounding for table values
Usage
table_glue(..., rspec = NULL, .sep = "", .envir = parent.frame())
Arguments
... |
strings to round and format. Multiple inputs are concatenated together. Named arguments are not supported. |
rspec |
a |
.sep |
Separator used to separate elements |
.envir |
environment to evaluate each expression in. |
Value
a character vector of length equal to the vectors supplied in ...
See Also
Other table helpers:
table_ester()
,
table_pvalue()
,
table_value()
Examples
x <- runif(10)
y <- runif(10)
table_glue("{x} / {y} = {x/y}")
table_glue("{x}", "({100 * y}%)", .sep = ' ')
df = data.frame(x = 1:10, y=1:10)
table_glue("{x} / {y} = {as.integer(x/y)}", .envir = df)
table_glue("{x} / {y} = {as.integer(x/y)}")
with(df, table_glue("{x} / {y} = {as.integer(x/y)}"))
mtcars$car <- rownames(mtcars)
# use the default rounding specification
table_glue(
"the {car} gets ~{mpg} miles/gallon and weighs ~{wt} thousand lbs",
.envir = mtcars[1:3, ]
)
# use your own rounding specification
rspec <- round_spec()
rspec <- round_using_decimal(rspec, digits = 1)
table_glue(
"the {car} gets ~{mpg} miles/gallon and weighs ~{wt} thousand lbs",
rspec = rspec,
.envir = mtcars[1:3, ]
)
[Package table.glue version 0.0.3 Index]