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

Should deferred_run() work within knitr? #235

Closed
maelle opened this issue Oct 16, 2023 · 4 comments · Fixed by #251
Closed

Should deferred_run() work within knitr? #235

maelle opened this issue Oct 16, 2023 · 4 comments · Fixed by #251

Comments

@maelle
Copy link

maelle commented Oct 16, 2023

I observe that using deferred_run() doesn't work within R Markdown document, including reprexes. Is it supposed to work? The same code works fine in my R session, that is to say, the blop option is NULL after the call to deferred_run().

getOption("blop")
#> NULL

withr::local_options(blop = FALSE)

getOption("blop")
#> [1] FALSE

withr::deferred_run()

getOption("blop")
#> [1] FALSE

Created on 2023-10-16 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22)
#>  os       Ubuntu 20.04.6 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US.utf8
#>  collate  en_US.utf8
#>  ctype    en_US.utf8
#>  tz       Europe/Paris
#>  date     2023-10-16
#>  pandoc   3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version     date (UTC) lib source
#>  cli           3.6.1       2023-03-23 [1] RSPM
#>  digest        0.6.33      2023-07-07 [1] CRAN (R 4.2.0)
#>  evaluate      0.22        2023-09-29 [1] CRAN (R 4.2.0)
#>  fastmap       1.1.1       2023-02-24 [1] RSPM
#>  fs            1.6.3       2023-07-20 [1] RSPM (R 4.2.0)
#>  glue          1.6.2       2022-02-24 [1] RSPM (R 4.2.0)
#>  htmltools     0.5.6.1     2023-10-06 [1] CRAN (R 4.2.0)
#>  knitr         1.44        2023-09-11 [1] RSPM (R 4.2.0)
#>  lifecycle     1.0.3       2022-10-07 [1] RSPM (R 4.2.0)
#>  magrittr      2.0.3       2022-03-30 [1] RSPM (R 4.2.0)
#>  purrr         1.0.2       2023-08-10 [1] RSPM (R 4.2.0)
#>  R.cache       0.16.0      2022-07-21 [1] CRAN (R 4.2.0)
#>  R.methodsS3   1.8.2       2022-06-13 [1] RSPM
#>  R.oo          1.25.0      2022-06-12 [1] RSPM
#>  R.utils       2.12.2      2022-11-11 [1] RSPM (R 4.2.0)
#>  reprex        2.0.2       2022-08-17 [1] RSPM
#>  rlang         1.1.1       2023-04-28 [1] RSPM (R 4.2.0)
#>  rmarkdown     2.25        2023-09-18 [1] RSPM (R 4.2.0)
#>  rstudioapi    0.15.0      2023-07-07 [1] CRAN (R 4.2.0)
#>  sessioninfo   1.2.2       2021-12-06 [1] RSPM (R 4.2.0)
#>  styler        1.10.2      2023-08-29 [1] RSPM
#>  vctrs         0.6.4       2023-10-12 [1] RSPM
#>  withr         2.99.0.9000 2023-10-09 [1] Github (r-lib/withr@0c5254e)
#>  xfun          0.40        2023-08-09 [1] RSPM (R 4.2.0)
#>  yaml          2.3.7       2023-01-23 [1] RSPM
#> 
#>  [1] /home/maelle/R/x86_64-pc-linux-gnu-library/4.2
#>  [2] /opt/R/4.2.0/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@hadley
Copy link
Member

hadley commented Jan 9, 2024

It does seem like this should work.

@lionel-
Copy link
Member

lionel- commented Jan 12, 2024

We're throwing an error for now, though that's still something we'd like to fix at some point. It will involve using a different strategy for attaching handlers to the knitr frame.

@lionel-
Copy link
Member

lionel- commented Jan 16, 2024

Fixed after all!

@maelle
Copy link
Author

maelle commented Jan 16, 2024

Fantastic, thank you! 🎉

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 a pull request may close this issue.

3 participants