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

Implement {glue} to construct paste/sprintf messages #378

Closed
njtierney opened this issue Apr 21, 2021 · 1 comment · Fixed by #452
Closed

Implement {glue} to construct paste/sprintf messages #378

njtierney opened this issue Apr 21, 2021 · 1 comment · Fixed by #452
Assignees
Labels
Milestone

Comments

@njtierney
Copy link
Collaborator

Slightly easier to maintain and use from a developer standpoint.

E.g.,

cat(
paste0(
  "\n\ngreta requires Python and several Python packages ",
  "to be installed, but no Python installation was detected.\n",
  "You can install Python directly from ",
  "https://www.python.org/downloads/ ",
  "or with the Anaconda distribution from ",
  "https://www.anaconda.com/download/"
)
)
#> 
#> 
#> greta requires Python and several Python packages to be installed, but no Python installation was detected.
#> You can install Python directly from https://www.python.org/downloads/ or with the Anaconda distribution from https://www.anaconda.com/download/

library(glue)

glue(
  "
  
  
  greta requires Python and several Python packages to be installed, but no \\
  Python installation was detected.
  You can install Python directly from https://www.python.org/downloads/ \\
  or with the Anaconda distribution from https://www.anaconda.com/download/"
)
#> 
#> 
#> greta requires Python and several Python packages to be installed, but no Python installation was detected.
#> You can install Python directly from https://www.python.org/downloads/ or with the Anaconda distribution from https://www.anaconda.com/download/

Created on 2021-04-21 by the reprex package (v2.0.0)

and instead of

paste0(
        text,
        ifelse(is.null(text), "", " and "),
        "TensorFlow Probability isn't installed"

You write

glue("{text}, {ifelse(is.null(text), '', ' and '} TensorFlow Probability \\
     isn't installed")
@njtierney
Copy link
Collaborator Author

See also the glubort helper function that a lot of tidyverse pkgs seem to use:

https://github.com/DavisVaughan/slider/blob/579c3042d51fc48fb400d2dd6810a2677756e695/R/utils.R#L1-L3

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

Successfully merging a pull request may close this issue.

1 participant