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

Change calls to knitr:::%n% to %||% as %||% is a base function #1480

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

cgrandin
Copy link
Contributor

The functions knitr:::%n% and %||% are identical, but %||% is in base and %n% is an internal function of the knitr package.

The R documentation states that using triple colon operator inside packages is typically a design mistake (https://stat.ethz.ch/R-manual/R-devel/library/base/html/ns-dblcolon.html) and in this case it can and should be avoided.

@CLAassistant
Copy link

CLAassistant commented Nov 13, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This operator is available only in R 4.4, so we have to define it for R versions below 4.4 like https://github.com/yihui/litedown/blob/376248c309f005175fa7f81e154f46b72c694a37/R/utils.R#L21

BTW, using ::: is not a design mistake in this particular case. I'm the maintainer of both bookdown and knitr, and I'm just stealing my own function from one package to another :)

R/utils.R Show resolved Hide resolved
@yihui yihui changed the title Change calls to knitr:::%n% to %||% as %||% is a base function Change calls to knitr:::%n% to %||% as %||% is a base function Nov 13, 2024
R/utils.R Show resolved Hide resolved
@yihui yihui merged commit bd78cf8 into rstudio:main Nov 13, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

3 participants