关于 rstudio:防止 r-markdown 展开代码/功能 | 珊瑚贝

prevent r-markdown from unfolding code/function


这是我的 r-markdown 代码:

1
2
3
4
5
6
7
8
9
10
“`{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
“`
“`{r}

test_funciton <- function(){<->}

3+5

“`

观察 test_function 是否折叠。现在,当我执行 3+5 行时,我最终得到以下视图:

1
2
3
4
5
6
7
8
9
10
11
12
“`{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
“`
“`{r}

test_funciton <- function(){
  print(‘test’)
}

3+5

“`

test_function 现在已展开。我想知道我是否可以阻止这种展开的行为?

  • 你可以把 code_folding:hide 放在你的 YAML 部分。
  • @Matt 谢谢,我跑了 > code_folding:hide 又回来了 Error: object ‘code_folding’ not found
  • 您是否在 html_output: 之后将其放入您的 YAML 中?此链接可能会有所帮助
  • @Matt,这是我的 YAML 部分的外观:— title:”Test” author:”Test” date:”11/5/2019″ output: html_document code_folding:hide —
  • html_document 之后需要 :
  • @Matt,再次感谢你。这是新格式:— title:”Test” output: html_document: code_folding:hide —,错误是 Error: object ‘output’ not found。我阅读了您的链接,但我认为它与我的问题无关。阅读更多…


你试过这个答案吗?
我试图在我的 RStudio v1.2.5033 中重现您的问题,它对我有用。

Tools > Global Options > R Markdown > Uncheck: Show output inline for all R Markdown Documents.

That should disable inline code chunk output when you’re editing R Markdown documents.
Does that get you what you’re asking?

  • 谢谢,我会试一试,但我的问题不是关于输出,而是关于代码折叠和展开。
  • 我知道这似乎是不相关的,但是取消选中此选项使我在 IDE 中获得了您描述的预期行为。
  • 我的意思是,我只选择了块内的 3+5 ,运行它,并且函数没有展开。
  • 这不起作用。代码仍将展开。


来源:https://www.codenong.com/59159943/

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?