Skip to content

Commit a089b23

Browse files
authored
Update the options vignette (#1092)
Closes #1066 Changes: 1. Verified the current options we support. - ✅ teal (`teal.load_nest_code`, `teal.show_js_log`, `teal.bs_theme`) - ✅ teal.logger (`teal.log_level`) - ✅ teal.widgets (`teal.basic_table_args`, `teal.ggplot2_args`, `teal.plot_dpi`) - ✅ teal.slice (`teal.threshold_slider_vs_checkboxgroup`) - ❌ teal.modules.general (`ggplot2.discrete.colour`) - ❌ teal.modules.clinical (`ggplot2.discrete.colour`, `tmc_default_total_label`) 2. Removed the context of where the options were implemented, it seems unnecessary. 3. Reordered the options in the way that important and most used are at the top and are grouped when possible. And, moved the depreciated options to the bottom.
1 parent b6015f0 commit a089b23

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

vignettes/teal-options.Rmd

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Modifying a teal Application With R Options"
3-
author: "Paweł Rucki"
3+
author: "NEST CoreDev"
44
output: rmarkdown::html_vignette
55
vignette: >
66
%\VignetteIndexEntry{Modifying a teal Application With R Options}
@@ -11,7 +11,7 @@ editor_options:
1111
---
1212

1313
# Motivation
14-
Some `R` packages use `options` to modify their runtime behavior. These usually specify default values for internal functions or determine responses to users actions. For example, `testthat` uses an option `testthat.progress.max_fails` to define a default number of failed expectations before the testing functions terminate execution. While some of these adjustable values can be exposed as function parameters, some are confined to an option. This vignette details the options available to users of `teal`, `teal.logger`, `teal.widgets`, `teal.modules.general`, `teal.modules.clinical`.
14+
Some `R` packages use `options` to modify their runtime behavior. They usually specify sensible default values for internal function arguments or determine responses to users actions. For example, `testthat` uses an option `testthat.progress.max_fails` to define a default number of failed expectations before the testing functions terminate execution. While some of these adjustable values can be exposed as function parameters, some are confined to an option. This vignette details the options available in the package `teal` and it's supporting packages `teal.logger`, `teal.widgets`, and `teal.slice`.
1515

1616
# Setting an option
1717
At any time during an interactive session, you can change an option using:
@@ -33,42 +33,23 @@ getOption("option_to_set")
3333
Once set, the value of an option persists during a session, but it returns to the default value in a new session. Make sure to change the options after all the `teal`-related packages are loaded because some of them initialize the options themselves and will overwrite your custom values.
3434

3535
# Options used in a `teal` application
36-
### `teal.log_layout` (`character`)
37-
This defines the layout of a log message used in a `teal` application. `teal` uses this layout to format the emitted log messages. Read the documentation of `teal.logger::register_logger` for more information.
38-
39-
Default: `"[{level}] {format(time, \"%Y-%m-%d %H:%M:%OS4\")} pid:{pid} token:[{token}] {ans} {msg}"`.
40-
41-
Note that this layout is formatted by the `glue` package.
42-
43-
### `teal.log_level` (`character`)
44-
This is the logging level threshold used in a `teal` application. A `teal` application will not emit logs below this level. Read the documentation of `teal.logger::register_logger` for more information. Possible values: `"TRACE"`, `"INFO"`, `"WARNING"`, `"ERROR"`. See the documentation of `logger::TRACE` for all possible values of logging threshold and more information on what it does.
45-
46-
Default: `"INFO"`.
4736

48-
Note that there are two levels considered less severe than `"INFO"`: `"DEBUG"` and `"TRACE"`. In order to see the log messages for these two levels as well, change the log level from the default to `"TRACE"`, the least severe log level.
49-
50-
### `teal_logging`
51-
Deprecated.
37+
### `teal.bs_theme` (`bslib::bs_theme` object)
38+
This option controls the bootstrap theme and version used in `teal` apps. Achieve better UX with the customized UI of an app.
39+
Please see the [vignette on Bootstrap themes](bootstrap-themes-in-teal.html) to read more about the functionality.
5240

53-
### `teal_show_js_log`
54-
Deprecated in favor of `teal.show_js_log` (see below).
41+
Default: `NULL`
5542

56-
### `teal.show_js_log` (`logical`)
57-
This indicates whether to print the `JavaScript` console logs to the `R` console. If set to `TRUE`, the logs will be printed; otherwise, they won't.
43+
### `teal.load_nest_code` (`character`)
44+
The value of this option is appended to the top of the code rendered when using the `Show R Code` modal button.
5845

59-
Default: `FALSE`.
46+
Default: `"# Add any code to install/load your NEST environment here"`.
6047

6148
### `teal.threshold_slider_vs_checkboxgroup` (`numeric`)
6249
This is the threshold that determines if a variable is treated as a factor in the filter panel. If the number of unique values of a variable is less than this threshold the variable will be treated as a factor instead of its original class. As an example, imagine `teal.threshold_slider_vs_checkboxgroup` equals to 2. Then a numeric variable `c(1, 1, 1)`, which has only one unique value, is treated as a factor in the filter panel (and in the filter panel only!). The filter panel creates a checkbox widget to filter values from this variable, as it would for a factor variable, instead of the usual numeric range selector.
6350

6451
Default: 5.
6552

66-
### `teal.load_nest_code` (`character`)
67-
The value of this option is appended to the top of the code rendered when using the `Show R Code` modal button. See the documentation of `teal::get_rcode` for more information.
68-
69-
Default: `"# Add any code to install/load your NEST environment here"`.
70-
71-
## `teal.widgets` package
7253
### `teal.basic_table_args` (`basic_table_args` object)
7354
This specifies the list of arguments passed to every call to `rtables::basic_table` made in a `teal` application. This can be used to format `rtables` without making any changes to the application code. See the documentation of `teal.widgets::basic_table_args` for more information.
7455

@@ -80,12 +61,34 @@ This option allows modifying labels and themes of all `ggplot2` plots in a `teal
8061
Default: `teal.widgets::ggplot2_args()`.
8162

8263
### `teal.plot_dpi` (integer value 24 or larger)
83-
This option controls the dots per inch of the graphs rendered and downloaded when using `plot_with_settings`.
64+
This option controls the dots per inch of the graphs rendered and downloaded when using the module `plot_with_settings` from the `teal.widgets` package.
8465

8566
Default: 72
8667

87-
### `teal.bs_theme` (`bslib::bs_theme` object)
88-
This option controls the bootstrap theme and version used in `teal` apps. Achieve better UX with the customized UI of an app.
89-
Please visit the vignette on Bootstrap themes to read more about the functionality.
68+
### `teal.log_layout` (`character`)
69+
This defines the layout of a log message used in a `teal` application. `teal` uses this layout to format the emitted log messages. Read the documentation of `teal.logger::register_logger` for more information.
9070

91-
Default: `NULL`
71+
Default: `"[{level}] {format(time, \"%Y-%m-%d %H:%M:%OS4\")} pid:{pid} token:[{token}] {ans} {msg}"`.
72+
73+
Note that this layout is formatted by the `glue` package.
74+
75+
### `teal.log_level` (`character`)
76+
This is the logging level threshold used in a `teal` application. A `teal` application will not emit logs below this level. Read the documentation of `teal.logger::register_logger` for more information. Possible values: `"TRACE"`, `"INFO"`, `"WARNING"`, `"ERROR"`. See the documentation of `logger::TRACE` for all possible values of logging threshold and more information on what it does.
77+
78+
Default: `"INFO"`.
79+
80+
Note that there are two levels considered less severe than `"INFO"`: `"DEBUG"` and `"TRACE"`. In order to see the log messages for these two levels as well, change the log level from the default to `"TRACE"`, the least severe log level.
81+
82+
### `teal.show_js_log` (`logical`)
83+
This indicates whether to print the `JavaScript` console logs to the `R` console. If set to `TRUE`, the logs will be printed; otherwise, they won't.
84+
85+
Default: `FALSE`.
86+
87+
88+
# Deprecated options
89+
90+
### `teal_logging`
91+
Deprecated in favor of using the `teal.logger` package for logging.
92+
93+
### `teal_show_js_log`
94+
Deprecated in favor of `teal.show_js_log` (see above).

0 commit comments

Comments
 (0)