Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incongrous function name #3

Open
gregorp opened this issue Feb 1, 2019 · 2 comments
Open

Incongrous function name #3

gregorp opened this issue Feb 1, 2019 · 2 comments

Comments

@gregorp
Copy link

gregorp commented Feb 1, 2019

The bbc_style function seems very similar to any other ggplot theme function, like the theme_grey, theme_classic, theme_light, etc., built in to the ggplot2 package, or many others like those in the ggthemes package.

Except the name.

I think it'd be great to change the name of the function to theme_bbc if you'd like greater visibility consider submitting it to ggthemes. With theme_economist, theme_fivethirtyeight, and theme_wsj, theme_bbc would feel right at home :)

@gregorp
Copy link
Author

gregorp commented Feb 1, 2019

Meant to add in my original post that it looks lovely :)

If you want to make this change internally as well, a nice way to go about renaming (to not break any existing code) is to make a copy. Rename the theme theme_bbc and add the line

bbc_style <- theme_bbc

Try to wean off of bbc_style. In a couple months, change it to

bbc_style <- function() {
  warning("bbc_style is on a deprecation, please use theme_bbc() instead")
  theme_bbc()
}

Eventually upgrade the warning to an error

bbc_style <- function() {
  stop("bbc_style is deprecated, please use theme_bbc() instead")
}

@jonocarroll
Copy link

FYI, there's a canonical way to achieve this:

## soft deprecate a function
bbc_style <- function() {
  .Deprecated("theme_bbc")
  
  ## existing code
  list(a = 2, b = 3)
}
## produces a warning
bbc_style()
#> Warning: 'bbc_style' is deprecated.
#> Use 'theme_bbc' instead.
#> See help("Deprecated")
#> $a
#> [1] 2
#> 
#> $b
#> [1] 3

## hard deprecate a function
bbc_style <- function() {
  .Defunct("theme_bbc")
}
## produces an error
bbc_style()
#> Error: 'bbc_style' is defunct.
#> Use 'theme_bbc' instead.
#> See help("Defunct")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants