3

What's the difference, if any, in terms of control, between using ERTs, as in the minimal example, and using, instead, LyX' own Custom Insets (Chunk, S/R expression, Sweave options) for knitr?

I've replicated the "minimal" examples, using also the Options inset inside a Chunk inset, and I can see no differences. (I am still ignorant on how to use the Sweave options inset.)

Nikos Alexandris
  • 708
  • 2
  • 22
  • 36

1 Answers1

3

There are currently only small differences. Using the chunk inset takes a bit more time, unless you set up shortcuts, because you have to insert the inset, then insert the options. The main advantages are simply that it is marked as a chunk, and you do not have to manually enter "<<>>=" and "@". Sometimes I forget whether it is "<>=" and sometimes I forget the equals sign so this is nice for my bad memory. If you want to get fancy, you can customize the font size and color within the chunk inset (you could do this for ERT also but that would apply for all ERTs, not just knitr chunks). If interested, see Help > Customization in LyX.

We hope to implement some features that might enhance the use of chunk insets over ERT. For example, it would be nice to navigate chunk insets in the outline pane. This is http://www.lyx.org/trac/ticket/7790 It would also be nice to ensure that knitr chunks start and end with newlines. This would prevent some not-so-rare problems. This is http://www.lyx.org/trac/ticket/8875

It comes down to a matter of preference. I prefer the chunk inset, but note that the author of knitr prefers ERT.

scottkosty
  • 2,410
  • 1
  • 16
  • 22
  • Having not to type "<<>>= @" is a big plus. And navigating through chunks would be awesome :-). Thank you for the (time-saving) details. – Nikos Alexandris Sep 12 '14 at 18:07
  • Is it true, as it stands now, that it's not easy/possible to replicate with LyX' custom insets the following (taken from knitr-graphics.lyx): `<>= plot(cars) boxplot(cars$dist,xlab='dist') @`? I can't see a straitforward way to put two plots side by side, other than using boxes(=minipages)? – Nikos Alexandris Sep 19 '14 at 23:12