Name conventions for options

tidyverse
options
style
conventions

#1

As with the rest of base R, the naming conventions for options are a bit... inconsistent.

To take a few examples from the documentation:

add.smooth
askYesNo
matprod
PCRE_limit_recursion

Yikes!

So, Is there an established convention for option names in/adjacent to the tidyverse? My initial suspicion was that one should follow the standard for object names:

Variable and function names should use only lowercase letters, numbers, and _ . Use underscores ( _ ) (so called snake case) to separate words within a name.

This style is seen in some packages like r-lib/keyring:

  backend <- getOption("keyring_backend", "")

However in (for example) devtools the convention seems to be to use library.option.name as in revdep_check:

  libpath = getOption("devtools.revdep.libpath"),

Is there a preferred convention for options going forward?


#2

My sense of our convention is: package.option_name :grimacing:.

So I separate package name from option name with . and use snack_case for the option name, i.e. I separate words with _.


#3

use snack_case for the option name

Snack case is the tastiest of cases.

:joy:


#4

Oops! Make that snake_case :snake:


#5

Thanks, Jenny. That seems pretty reasonable to me. Is it worth me submitting an issue to the tidyverse style guide, or am I being a massive pedant?


#6

I think it's fine to open an issue at https://github.com/tidyverse/style, where I trust my view on option names will be recognized as the One True Way :joy: