Based on Yihui feedback, the way to go is as follows:
```{r setup, purl=FALSE}
knit_hooks$set(purl = hook_purl)
opts_template$set(nopurl = list(purl=FALSE))
opts_template$set(dopurl = list(purl=TRUE))
```
```{r test}
print(1)
```
```{r test2, opts.label='nopurl'}
print(2)
```
```{r test3, opts.label='dopurl'}
print(3)
```
With this approach, you do not need:
purl('test.Rmd')
You just:
knit('test.Rmd')
and get both a regular file test.mdand test.R. The latter is as follows:
print(1)
print(3)
As you can see, when given knit_hooks$set(purl = hook_purl), the default behavior for chunks is shredding.
nopurl dopurl , (no-) .
, :
N.B. , R script, 'purl()' , "knit()" . "Knit()" ( , , , R, "envir" ..). , "knit()" , "knit()" , R script, 'purl()'. , .
knit_hooks$set(purl = hook_purl) purl=FALSE, .