Learn R Programming

DescTools (version 0.99.19)

DescToolsOptions: DescTools Options

Description

Get and set a variety of options which affect the way in which DescTools functions display results.

Usage

DescToolsOptions(..., default = NULL, reset = FALSE)

Arguments

...
any options can be defined, using name = value. However, only the ones below are used by DescTools functions.
default
if the specified option is not set in the options list, this value is returned. This facilitates retrieving an option and checking whether it is set and setting it separately if not.
reset
logical. If this is set to TRUE, the options will be overwritten with their default values. Other arguments will be ignored in this case. Default is FALSE.

Value

For a given vector of strings the current value set for option x, or NULL if the option is unset.For a list of named values the options will be set and a list with the previous values of the options changed will be returned invisibly.

Details

Invoking DescToolsOptions() with no arguments returns a list with the current values of the options. Note that not all options listed below are set initially. To access the value of a single option, one can simply use DescToolsOptions("plotit"). To set a new value use the same rationale as with the R options: DescToolsOptions(plotit=FALSE)

Options used by DescTools

Calling DescToolsOptions(reset=TRUE) will reset the options to these defaults:

options(DescTools = list(
  col       = c(hblue="#8296C4", hred="#9A0941", horange="#F08100"),
  digits    = 3,
  fixedfont = structure(list(name = "Consolas", size = 7), class = "font"),
  fmt       = list(abs = structure(list(digits = 0, big.mark = "'"),
                     name = "abs", label = "Number format for counts", default = TRUE,
                     class = "fmt"),
                   per = structure(list(digits = 1, fmt = "%"),
                     name = "per", label = "Percentage number format", default = TRUE,
                     class = "fmt"),
                   num = structure(list(digits = 3, big.mark = "'"),
                     name = "num", label = "Number format for floats", default = TRUE,
                     class = "fmt")
              ),
  footnote  = c("'", "\"", "\"\""),
  lang      = "engl",
  plotit    = TRUE,
  stamp     = expression(gettextf("%s/%s", Sys.getenv("USERNAME"),
                                  Format(Today(), fmt = "yyyy-mm-dd")))
))

This code can as well be copied and pasted to the users' RProfile file, in order to have the options permanently available.

See Also

Format, Pal

Examples

Run this code
DescToolsOptions("plotit")

## Not run: 
# 
# # Get all options, defaults are attributed as such
# DescToolsOptions()
# 
# # get some options
# DescToolsOptions("plotit", "lang")
# 
# # get some potentially undefined option, while taking a user default and
# # overriding system defaults
# DescToolsOptions("stamp", default="Condor, 2016")
# 
# # get an undefined option, should return default
# DescToolsOptions("stampede", default="Condor, 2016")
# 
# # set options, while getting the old values
# opt <- DescToolsOptions(plotit=789, lang="portugues")
# DescToolsOptions()
# # output the old values
# opt
# 
# # just a single argument
# DescToolsOptions(digits=2)
# 
# # reset the old values
# DescToolsOptions(opt)
# DescToolsOptions()
# 
# # reset factory defaults
# DescToolsOptions(reset=TRUE)
# ## End(Not run)

Run the code above in your browser using DataLab