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
Conditional chunk evaluation only works for 'run all above' with explict TRUE/FALSE #6675
Comments
@RichardJActon Thank you for filing the issue! I can reproduce what you've described, but sometimes it ends up working; I haven't figured out the pattern, though. In addition to the described behavior, I see the following:
[The word sometimes will not appear any further.] Note: I tested this in RStudio Desktop 1.3.938 on MacOS 10.15.4 and RStudio Server on Ubuntu 18.0.4. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions. |
This is an advanced feature request, where the IDE would have to evaluate the variables that are part of the chunk when deciding whether to run the chunk. Right now we don't run any of your R code when making that decision. This is out of scope. |
After further discussion, we've changed our minds about this and will consider it in the future. There have been a large number of duplicate issues logged, and several upvotes, making this issue something we want to consider. |
Hi @mikebessuille & @ronblum - Just a note that this workflow is documented in "R Markdown: The Definitive Guide" here as well:
|
We have another example of this behavior in This is confusing for users because something that works when you knit does not work the same interactively in the IDE. As a side effect of this issue above, ---
title: "test"
output: html_document
params:
run: FALSE
---
# eval = FALSE
* won't evaluate when knitted
* won't evaluate when running all chunks ('Run All', 'Run all of the above', ...)
* will evaluate with 'Run current Chunk' (green arrow)
```{r, eval=FALSE}
cat('successful')
```
# eval = params$run
* won't evaluate when knitted
* will evaluate when running all chunks ('Run All', 'Run all of the above', ...)
* will evaluate with 'Run current Chunk' (green arrow)
```{r, eval=params$run}
cat('successful')
```
# other engine
* Will evaluate correctly as bash chunk
```{bash, eval=TRUE}
Rscript -e "cat('successful')"
```
* Will be evaluated as a R chunk leading to an error
```
#> Error: unexpected string constant in "Rscript -e "cat('successful')""
```
```{bash, eval=params$run}
Rscript -e "cat('successful')"
``` |
Whilst the
eval
chunk option works fine theknitr
they do not see to work as expected interactively in Rstudio. Weirdly explicitly specifying a literal TRUE / FALSE works but using a variable that contains a TRUE / FALSE value does not.Though it might be a peculiarity of
params
so tested with an ordinary variable:System details
The text was updated successfully, but these errors were encountered: