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, ]
)
Run the code above in your browser using DataLab