最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - toggle showhide code in RMarkdown - Stack Overflow

programmeradmin2浏览0评论

I am generating an HTML report using Rmarkdown in which I want the user to have an option of looking at code (when they want by using a toggle show/hide code) before each section or figure.

I am wondering if there is an option to do so globally and individually for each code chunk.

I have looked at some previous solutions using javascript, but I am not familiar with the language. I was hoping there is an option I can choose within Rmarkdown.

Previous approaches using javascript are shown here and here, but I am not sure how to include these in my Rmarkdown file. I have tried the following, but it didn't work

<script src="toggleR.js"></script> 
```{r}
summary(cars)
```

A working example in Rmarkdown would be extremely helpful!!

Thanks

I am generating an HTML report using Rmarkdown in which I want the user to have an option of looking at code (when they want by using a toggle show/hide code) before each section or figure.

I am wondering if there is an option to do so globally and individually for each code chunk.

I have looked at some previous solutions using javascript, but I am not familiar with the language. I was hoping there is an option I can choose within Rmarkdown.

Previous approaches using javascript are shown here and here, but I am not sure how to include these in my Rmarkdown file. I have tried the following, but it didn't work

<script src="toggleR.js"></script> 
```{r}
summary(cars)
```

A working example in Rmarkdown would be extremely helpful!!

Thanks

Share Improve this question edited May 23, 2017 at 12:08 CommunityBot 11 silver badge asked Aug 18, 2015 at 15:36 SatyaSatya 1,8001 gold badge16 silver badges40 bronze badges 2
  • The accepted answer for your second link should give you what you want. For output chunks take a look at this: stackoverflow./questions/37755037/… – Martin Schmelzer Commented Jun 16, 2016 at 7:41
  • Possible duplicate of How to hide code in RMarkdown, with option to see it – Martin Schmelzer Commented Jun 16, 2016 at 14:12
Add a ment  | 

1 Answer 1

Reset to default 4

From the answer to a similar question by Yihue -this functionality has now been added as code folding. See more at http://rmarkdown.rstudio./html_document_format.html

发布评论

评论列表(0)

  1. 暂无评论