[R] a knitr question
Yihui Xie
xie at yihui.name
Wed Jul 30 20:20:16 CEST 2014
As a reader, I often want to run the code by myself _while_ I'm
reading a particular part of an article/report. I find it convenient
to be able to copy the code as I'm reading it, instead of minimizing
my current window, opening an R script, and running the part that I'm
interested in. Of course, this may not work if the code I copy is not
self-contained; your purl() approach certainly has an advantage
sometimes.
I do not see a whole lot of value in maintaining the same appearance
of the R code in the R console and a report. You can teach your
students what the prompt characters mean, and I think that is enough.
Journal of Statistical Software requires "R> " as the prompt character
(which is worse), and your students will probably be confused when
reading JSS papers if they have been seeing the default prompts all
the time. I see the point of keeping prompts (i.e. I do not completely
disagree), but I do not think it is an essential or important thing to
do. Personally I prefer reading "vanilla" code, and >/+ may confuse my
eyes occasionally, e.g.
> z > 5
> x +
+ y
(More on prompts:
http://yihui.name/en/2013/01/code-pollution-with-command-prompts/)
Re Rich: yes, I'm aware of approaches of post-processing the prompts,
but this problem would not have existed in the first place if we do
not include prompts at all. I'm not sure if it makes much sense to
create some mess and clean it afterwards.
Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name
On Wed, Jul 30, 2014 at 12:50 PM, Greg Snow <538280 at gmail.com> wrote:
> My preference when teaching is to have the code and results look the
> same as it appears in the R console window, so with the prompts and
> without the output commented. But then I also `purl` my knitr file to
> create a script file to give to the students that they can copy and
> paste from easily.
>
More information about the R-help
mailing list