r - Showing code chunk name in output in RMarkdown -


as known in rmarkdown code chunks can named this:

```{r chunkname}  plot(x,y)  ``` 

is possible showing chunkname in output document?

you can use knitr::opts_current$get()$label

example:

```{r cars} library(knitr) opts_current$get()$label plot(cars) ``` 

it work outside of chunk, in inline r code. output label of last chunk.

you can of course save labels in vector use them later, instance custom hook:

```{r knitr_setup} library(knitr) ll <- opts_current$get()$label knit_hooks$set(label_list = function(before, options, envir) {     if(before) ll <<- c(ll,opts_current$get()$label) }) opts_chunk$set(label_list=true) ``` 

ll contain list of chunk labels. however, cannot access names of chunks not yet ran.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -