tbl_string: Table strings

Description Usage Arguments Value Examples

View source: R/tbl_string.R

Description

Table strings

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
tbl_string(
  ...,
  .sep = "",
  .envir = parent.frame(),
  round_half_to_even = FALSE,
  breaks = c(1, 10, Inf),
  decimals = c(2, 1, 0),
  miss_replace = "--",
  big_mark = ",",
  big_interval = 3L,
  small_mark = "",
  small_interval = 5L,
  decimal_mark = getOption("OutDec"),
  zero_print = NULL,
  trim = TRUE
)

Arguments

...

Strings to format. Multiple inputs are concatenated together before formatting. Named arguments are not supported.

.sep

Separator used to separate elements

.envir

environment to evaluate each expression in.

round_half_to_even

a logical value. If TRUE, then when the fractional part of x is half-way between two rounding boundaries, it will be rounded to the even boundary nearest to x. For example, +23.5 becomes +24, as does +24.5; while −23.5 becomes −24, as does −24.5. If FALSE, halves are automatically rounded to the boundary with highest absolute value.

breaks

a positive, monotonically increasing numeric vector designating rounding boundaries. With breaks = c(1, 10, 100, 1000) and decimals = c(2, 1, 0)

decimals

a numeric vector of equal length to breaks that indicates how many decimals to round to in the numeric range designated by breaks. (see notes for example). Allowed values are 0 <= decimals <= 20.

miss_replace

a character string that replaces missing values.

big_mark

a character value used to separate number groups to the left of the decimal point. See prettyNum for more details on this. Set this input to ” to negate it's effect.

big_interval

a numeric value indicating the size of number groups for numbers before (hence big) the decimal.

small_mark

a character value used to separate number groups to the right of the decimal point.

small_interval

a numeric value indicating the size of number groups for numbers after (hence small) the decimal.

decimal_mark

the character to be used to indicate the numeric decimal point.

zero_print

a logical value, character string or NULL value specifying if and how zeros should be formatted specially. Useful for pretty printing 'sparse' objects.

trim

a logical value; if FALSE, logical, numeric and complex values are right-justified to a common width: if TRUE the leading blanks for justification are suppressed.

Value

a character vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
x <- runif(10)
y <- runif(10)

tbl_string("{x} / {y} = {x/y}")

tbl_string("{x}", "({100 * y}%)", .sep = ' ')

df = data.frame(x = 1:10, y=1:10)

tbl_string("{x} / {y} = {as.integer(x/y)}", .envir = df)
tbl_string("{x} / {y} = {as.integer(x/y)}", .envir = NULL)

with(df, tbl_string("{x} / {y} = {as.integer(x/y)}"))

bcjaeger/tblStrings documentation built on Aug. 17, 2020, 9:36 a.m.