yihui/knitr — Issue #164: Code externalization: generate chunk labels from section header text
Author: MartinInFrankfurtAM
Created: 2012-03-07 00:13:34+00:00
State: open

May I suggest an unmet need:
A LyX-button to harmonize the section header texts with the respective chunk labels.

Background:
So far, the chunk labels in the exported R-code file have no clear relation to the header text of the respective section in LyX-document unless they are aligned and kept aligned manually in LyX.

When I copy/paste/edit my LyX documents to adapt the LyX-documented R-script to the individual dataset on which I work, I run into the versionitis condition: name conflicts betwen chunks and loss of orientation in the external code file.
I do put my pseudocode comments into section headers to generate a structured pseudocode in form of the TOC.
However, when I want to single step through a chunk in the extrenal code file, I depend on the chunk labels to find my way.

So I wrote myself a small "Lyx"-parser to copy the Part/(sub)(sub()section header text into a buffer and put some cleansed version of the local header text for the chunk with section number and chunk number within the (sub)(sub)section as label into the chunk header. My cleansing targets include blanks, commas, "insets", and equal signs so far.

The benefit:
No more chunk label conflicts and a consistent relation between LyX-documnt structure and external R-code!
My R-code is operational but would need some expert editing if not a complete rewrite before sharing it in public.