Skip to content

Incongrous function name #3

Description

@gregorp

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 :)

Activity

  1. gregorp commented on Feb 1, 2019

    @gregorp
    Author

    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")
    }
    
  2. jonocarroll commented on Feb 3, 2019

    @jonocarroll

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions