Skip to contents

These functions format numeric values as character labels including the symbol for statistical parameter estimates suitable for adding to plots. The labels can be formatted as strings to be parsed as plotmath expressions, or encoded using LaTeX or Markdown.

Usage

plain_label(
  value,
  value.name,
  digits = 3,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

italic_label(
  value,
  value.name,
  digits = 3,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

bold_label(
  value,
  value.name,
  digits = 3,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

p_value_label(
  value,
  small.p = getOption("ggpmisc.small.p", default = FALSE),
  subscript = "",
  superscript = "",
  digits = 4,
  fixed = NULL,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

f_value_label(
  value,
  df1 = NULL,
  df2 = NULL,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

t_value_label(
  value,
  df = NULL,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

z_value_label(
  value,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

S_value_label(
  value,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

mean_value_label(
  value,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

var_value_label(
  value,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

sd_value_label(
  value,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

se_value_label(
  value,
  digits = 4,
  fixed = FALSE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

r_label(
  value,
  method = "pearson",
  small.r = getOption("ggpmisc.small.r", default = FALSE),
  digits = 3,
  fixed = TRUE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

rr_label(
  value,
  small.r = getOption("ggpmisc.small.r", default = FALSE),
  digits = 3,
  fixed = TRUE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

adj_rr_label(
  value,
  small.r = getOption("ggpmisc.small.r", default = FALSE),
  digits = 3,
  fixed = TRUE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

rr_ci_label(
  value,
  conf.level,
  range.brackets = c("[", "]"),
  range.sep = NULL,
  digits = 2,
  fixed = TRUE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

r_ci_label(
  value,
  conf.level,
  small.r = getOption("ggpmisc.small.r", default = FALSE),
  range.brackets = c("[", "]"),
  range.sep = NULL,
  digits = 2,
  fixed = TRUE,
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

Arguments

value

numeric The value of the estimate.

value.name

character The symbol used to represent the value, or its name.

digits

integer Number of digits to which numeric values are formatetd.

fixed

logical Interpret digits as indicating a number of digits after the decimal mark or as the number of significant digits.

output.type

character One of "expression", "latex", "tex", "text", "tikz", "markdown".

decimal.mark

character Defaults to the value of R option "OutDec".

small.p, small.r

logical If TRUE use lower case (\(p\) and \(r\), \(r^2\)) instead of upper case (\(P\) and \(R\), \(R^2\)),

subscript, superscript

character Text for a subscript and superscript to P symbol.

df, df1, df2

numeric The degrees of freedom of the estimate.

method

character The method used to estimate correlation, which selects the symbol used for the value.

conf.level

numeric critical P-value expressed as fraction in [0..1].

range.brackets, range.sep

character Strings used to format a range.

Value

A character string with formatting, encoded to be parsed as an R plotmath expression, as plain text, as markdown or to be used with

\(LaTeX\) within math mode.

See also

Examples

plain_label(value = 123, value.name = "n", output.type = "expression")
#> [1] "plain(n)~`=`~\"123.\""
plain_label(value = 123, value.name = "n", output.type = "markdown")
#> [1] "n = 123."
plain_label(value = 123, value.name = "n", output.type = "latex")
#> [1] "\\mathrm{n} = 123."
italic_label(value = 123, value.name = "n", output.type = "expression")
#> [1] "italic(n)~`=`~\"123.\""
italic_label(value = 123, value.name = "n", output.type = "markdown")
#> [1] "_n_ = 123."
italic_label(value = 123, value.name = "n", output.type = "latex")
#> [1] "\\mathit{n} = 123."
bold_label(value = 123, value.name = "n", output.type = "expression")
#> [1] "bold(n)~`=`~\"123.\""
bold_label(value = 123, value.name = "n", output.type = "markdown")
#> [1] "**n** = 123."
bold_label(value = 123, value.name = "n", output.type = "latex")
#> [1] "\\mathbf{n} = 123."

p_value_label(value = 0.345, digits = 2, output.type = "expression")
#> [1] "italic(P)~`=`~\"0.34\""
p_value_label(value = 0.345, digits = Inf, output.type = "expression")
#> [1] "italic(P)~`=`~\"0.345\""
p_value_label(value = 0.345, digits = 6, output.type = "expression")
#> [1] "italic(P)~`=`~\"3.450000\" %*% 10^{\"−01\"}"
p_value_label(value = 0.345, output.type = "markdown")
#> [1] "_P_ = 0.3450"
p_value_label(value = 0.345, output.type = "latex")
#> [1] "P = 0.3450"
p_value_label(value = 0.345, subscript = "Holm")
#> [1] "italic(P)[Holm]~`=`~\"0.3450\""
p_value_label(value = 1e-25, digits = Inf, output.type = "expression")
#> [1] "italic(P)~`<`~\"0.00100\""

f_value_label(value = 123.4567, digits = 2, output.type = "expression")
#> [1] "italic(F)~`=`~\"1.2\" %*% 10^{\"+02\"}"
f_value_label(value = 123.4567, digits = Inf, output.type = "expression")
#> [1] "italic(F)~`=`~\"1.2\" %*% 10^{\"+02\"}"
f_value_label(value = 123.4567, digits = 6, output.type = "expression")
#> [1] "italic(F)~`=`~\"123.457\""
f_value_label(value = 123.4567, output.type = "markdown")
#> [1] "_F_ = 123.5"
f_value_label(value = 123.4567, output.type = "latex")
#> [1] "\\mathit{F} = 123.5"
f_value_label(value = 123.4567, df1 = 3, df2 = 123,
              digits = 2, output.type = "expression")
#> [1] "italic(F)[3*\",\"*123]~`=`~\"1.2\" %*% 10^{\"+02\"}"
f_value_label(value = 123.4567, df1 = 3, df2 = 123,
              digits = 2, output.type = "latex")
#> [1] "F_{3,123} = 1.2 \times 10^{+02}"

t_value_label(value = 123.4567, digits = 2, output.type = "expression")
#> [1] "italic(t)~`=`~\"1.2\" %*% 10^{\"+02\"}"
t_value_label(value = 123.4567, digits = Inf, output.type = "expression")
#> [1] "italic(t)~`=`~\"1.2\" %*% 10^{\"+02\"}"
t_value_label(value = 123.4567, digits = 6, output.type = "expression")
#> [1] "italic(t)~`=`~\"123.457\""
t_value_label(value = 123.4567, output.type = "markdown")
#> [1] "_t_ = 123.5"
t_value_label(value = 123.4567, output.type = "latex")
#> [1] "\\mathit{t} = 123.5"
t_value_label(value = 123.4567, df = 12,
              digits = 2, output.type = "expression")
#> [1] "italic(t)[12]~`=`~\"1.2\" %*% 10^{\"+02\"}"
t_value_label(value = 123.4567, df = 123,
              digits = 2, output.type = "latex")
#> [1] "t_{123} = 1.2 \times 10^{+02}"

r_label(value = 0.95, digits = 2, output.type = "expression")
#> [1] "italic(R)~`=`~\"0.95\""
r_label(value = -0.95, digits = 2, output.type = "expression")
#> [1] "italic(R)~`=`~\"-0.95\""
r_label(value = 0.0001, digits = 2, output.type = "expression")
#> [1] "|italic(R)|~ < ~\"0.01\""
r_label(value = -0.0001, digits = 2, output.type = "expression")
#> [1] "|italic(R)|~ < ~\"0.01\""
r_label(value = 0.1234567890, digits = Inf, output.type = "expression")
#> [1] "italic(R)~`=`~\"0.12\""
r_label(value = 0.95, digits = 2, method = "pearson")
#> [1] "italic(R)~`=`~\"0.95\""
r_label(value = 0.95, digits = 2, method = "kendall")
#> [1] "italic(tau)~`=`~\"0.95\""
r_label(value = 0.95, digits = 2, method = "spearman")
#> [1] "italic(rho)~`=`~\"0.95\""

rr_label(value = 0.95, digits = 2, output.type = "expression")
#> [1] "italic(R)^2~`=`~\"0.95\""
rr_label(value = 0.0001, digits = 2, output.type = "expression")
#> [1] "italic(R)^2~`<`~\"0.01\""
rr_label(value = 1e-17, digits = Inf, output.type = "expression")
#> [1] "italic(R)^2~`=`~\"0.00\""

adj_rr_label(value = 0.95, digits = 2, output.type = "expression")
#> [1] "italic(R)[adj]^2~`=`~\"0.95\""
adj_rr_label(value = 0.0001, digits = 2, output.type = "expression")
#> [1] "italic(R)[adj]^2~`<`~\"0.01\""

rr_ci_label(value = c(0.3, 0.4), conf.level = 0.95)
#> [1] "\"95% CI [0.30, 0.40]\""
rr_ci_label(value = c(0.3, 0.4), conf.level = 0.95, output.type = "text")
#> [1] "95% CI [0.30, 0.40]"
rr_ci_label(value = c(0.3, 0.4), conf.level = 0.95, range.sep = ",")
#> [1] "\"95% CI [0.30,0.40]\""

r_ci_label(value = c(-0.3, 0.4), conf.level = 0.95)
#> [1] "\"95% CI [-0.30, 0.40]\""
r_ci_label(value = c(-0.3, 0.4), conf.level = 0.95, output.type = "text")
#> [1] "95% CI [-0.30, 0.40]"
r_ci_label(value = c(-0.3, 0.4), conf.level = 0.95, range.sep = ",")
#> [1] "\"95% CI [-0.30,0.40]\""
r_ci_label(value = c(-1.0, 0.4), conf.level = 0.95, range.sep = ",")
#> [1] "\"95% CI [-1.00,0.40]\""