Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to list all the global options that can be set for a package?

Tags:

package

r

options

From the vignette of tibble, I read that some changes can be made in global options through options to control the appearance of printing. However, I failed to find any manual for this options with in R. I even cannot known what fields can be added to global options for a package. So the question is:

For a package, can we get a list of fields (like tibble.print_max, tibble.print_min for tibble and BioC_mirror for utils) that can be set through options with in R before knowing them?

like image 384
mt1022 Avatar asked Apr 08 '17 17:04

mt1022


People also ask

What is global option in R?

Global option function such as options() and par() provides a way to control global settings. Here the GlobalOptions package provides a more general and controlable way to generate such functions, which can: validate the values (e.g. class, length and self-defined validations);

What does Options () do in R?

The options() function in R is used to set and examine different global options that affects the way in which R determines and returns its results.


1 Answers

Given the lack of required practice (e.g., on CRAN) for how to handle options in external (or even internal, as far as I can tell) packages, perhaps the most general approach is like this:

  1. Find the package on the CRAN mirror on GitHub. For example, here's tibble.

  2. Search for "option" within the repository to find all references to "option" in the package's code.

  3. Search through this. It takes a bit of a keen eye to know what to look for, but this is how I learned that all of tibble's options are listed on the main package help page (?"tibble-package"), because I found these lines with the search.

Step 3 can be automated better if you clone the repo to your machine and use command line tools, e.g.

cd package_dir
grep option R/*

(this is quite similar to the above, but enables the full flexibility of grep)

Just for additional confirmation, this approach led me to the right place for data.table and xtable as well.

like image 159
MichaelChirico Avatar answered Nov 15 '22 15:11

MichaelChirico