Code folding in external files with knitr and RStudio -


i can find no way insert syntactically acceptable rstudio style folds external r code file set use knitr document. or missing something. there several ways might done: 1) allow code header such as:

## @knitr q1 ---- 

or perhaps

## @knitr 'q1' ---- 

2) fold every code chunk (this change in rstudio), not general ideally like.

3) allow inclusion of kind of comment line in code files indicate fold. have not been able find way not add comment line previous code chunk.

[since posting this, have noticed arguments 'from' , 'to' in read_chunk() can regular expressions specify start , character strings code chunks. gives 1 way allow insertion of comment lines can specify folds. nice able use 1 or more of mechanisms 1-3 above.]

from knitr v1.2.11 , above, rstudio style code headers supported consistently in knitr. rule # ---- label:

  • one or more hashes # in beginning
  • followed @ least 4 dashes ----
  • followed chunk label
  • and optionally followed number of dashes

this supported in both read_chunk() , purl(), i.e., style of comments used in both importing , exporting code in knitr.

for rstudio support code-folding, however, have add @ least 4 dashes end of comment header, e.g.,

# ---- chunk-label ----------------------------- 

knitr 1.2.11 development version on github, become 1.3 on cran.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -