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

knitr::knit() evaluates chunk if false value of eval chunk option has a comment. #2199

Closed
3 tasks done
nplatonov opened this issue Nov 23, 2022 · 4 comments · Fixed by yihui/xfun#67
Closed
3 tasks done

Comments

@nplatonov
Copy link

nplatonov commented Nov 23, 2022

Input:

```{r}
evaluate <- FALSE
comment(evaluate) <- "not today"
```

```{r, eval=evaluate}
str(knitr::opts_current$get("eval"))
```

```{r}
xfun::session_info('knitr')
```

Output:

evaluate <- FALSE
comment(evaluate) <- "not today"
str(knitr::opts_current$get("eval"))
##  logi FALSE
##  - attr(*, "comment")= chr "not today"
xfun::session_info('knitr')
## R version 4.2.2 Patched (2022-11-17 r83369 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19044)
## 
## Locale:
##   LC_COLLATE=English_United Kingdom.utf8 
##   LC_CTYPE=English_United Kingdom.utf8   
##   LC_MONETARY=English_United Kingdom.utf8
##   LC_NUMERIC=C                           
##   LC_TIME=English_United Kingdom.utf8    
## 
## Package version:
##   evaluate_0.18   glue_1.6.2      graphics_4.2.2  grDevices_4.2.2
##   highr_0.9       knitr_1.40      magrittr_2.0.3  methods_4.2.2  
##   stats_4.2.2     stringi_1.7.8   stringr_1.4.1   tools_4.2.2    
##   utils_4.2.2     xfun_0.34       yaml_2.3.6

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/knitr').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Collaborator

cderv commented Nov 24, 2022

Thanks for the report. This is because we are using xfun::ifFALSE() to check the eval option, and it does not account for attributes

evaluate <- FALSE
comment(evaluate) <- "not today"
xfun::isFALSE(evaluate)
#> [1] FALSE
base::isFALSE(evaluate)
#> [1] TRUE

@cderv
Copy link
Collaborator

cderv commented Nov 24, 2022

@yihui I made a PR in case you think make xfun::isFALSE() same as base::isFALSE() a good idea.
Otherwise, we just need to account for attribute in identical()

@yihui
Copy link
Owner

yihui commented Jan 31, 2023

This should be fixed by ccb07c4, which has been included in the latest CRAN release (v1.42). Thanks!

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants