I'm able to reproduce the behavior with this Rmarkdown file
---
title: "Test of expression in chunk option"
author: "Drew Tyre"
date: "2019-04-11"
output: html_document
---
```{r setup, include=FALSE}
handout = FALSE
knitr::opts_chunk$set(echo = TRUE)
```
```{r, echo = !handout}
cat("this doesn't run with a valid r expression in chunk option\n")
cat("although it knits fine. \n")
```
This sounds similar to this topic, but the errors I get are different. I can knit this file successfully. But if I try to run the code chunks individually the one using an expression in the chunk option flashes green, but does not run the code inside the chunk. I get a "busy" indicator in the output panel of the chunk. In the console I get an error message: "Error in eval(ele) : object 'handout' not found". Restarting R and clearing output I start to get "File not found" errors when running chunks. Trying to run individual lines of code inside the chunk leads to similar issues. If I persist in trying, RStudio becomes unresponsive or gives an error about aborting.
Using RStudio Version 1.2.792 and
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.14.4
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] popbio_2.4.4 kableExtra_1.1.0 forcats_0.3.0 stringr_1.4.0 dplyr_0.8.0.1 purrr_0.3.2
[7] readr_1.3.1 tidyr_0.8.3 tibble_2.1.1 ggplot2_3.1.0 tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 cellranger_1.1.0 pillar_1.3.1 compiler_3.5.1 plyr_1.8.4
[6] tools_3.5.1 digest_0.6.18 viridisLite_0.3.0 evaluate_0.12 jsonlite_1.6
[11] lubridate_1.7.4 gtable_0.2.0 pkgconfig_2.0.2 rlang_0.3.1 cli_1.0.1
[16] rstudioapi_0.7 yaml_2.2.0 haven_1.1.2 xfun_0.5 withr_2.1.2
[21] xml2_1.2.0 httr_1.3.1 knitr_1.22 generics_0.0.2 hms_0.4.2
[26] webshot_0.5.0 grid_3.5.1 tidyselect_0.2.5 glue_1.3.1 R6_2.4.0
[31] readxl_1.1.0 rmarkdown_1.11 clipr_0.5.0 modelr_0.1.2 magrittr_1.5
[36] htmltools_0.3.6 backports_1.1.3 scales_1.0.0 rsconnect_0.8.8 rvest_0.3.2
[41] assertthat_0.2.0 colorspace_1.3-2 stringi_1.4.3 lazyeval_0.2.1 munsell_0.5.0
[46] broom_0.5.1.9000 crayon_1.3.4