[R] knitr: Was previously " Sweave: printing an underscore in the output from an R command"

Yihui Xie xie at yihui.name
Tue Sep 3 00:21:44 CEST 2013


On Mon, Sep 2, 2013 at 5:01 PM, David Epstein
<David.Epstein at warwick.ac.uk> wrote:
> Dear Yihui
> Thanks very much for drawing my attention to knitr, which I had not heard of before. Also thanks for pointing out the bug in Sweave, which I don't fully understand, but I don't want to spend time and effort on understanding it. So I hope you will find time to report the bug. I was pretty sure there was a bug somewhere that was preventing me from doing what I wanted to do in Sweave, but I misdiagnosed the source of the problem.
>
> I notice you didn't use print() or cat() in your short program for knitr. Is it the case that it's necessary to use print() or cat() with \Sexpr in Sweave, but unnecessary in knitr?

No, print() is superfluous; it is not necessary for either Sweave or
knitr, and cat() is a wrong way to go here, since cat() returns
character(0).

>
> I'll stick to Sweave for my current project, and try out knitr on my next project. I would welcome a list of documents about knitr that I should download, so as to make it as easy as possible to get started. I don't want to understand the internals of knitr, but I am interested in any documents on knitr, written by you or by others, directed at the user, rather than at programmers of packages.

Electronic version of the documentation: http://yihui.name/knitr Paper
version: http://www.amazon.com/gp/product/1482203537

You do not need to understand the internals of knitr, otherwise I
would not mention it at all. Depending on the size and complexity of
your project, it may take you a few seconds or hours to switch from
Sweave to knitr: http://yihui.name/knitr/demo/sweave/

>
> Is it convenient to use vi(m) to produce knitr source? Can vi(m) be integrated into the knitr package? My experience with editors designed specially to work with particular products (like the built-in editor for TeXWorks on the Mac) do not have the power of vi(m) and emacs, and I require this power.

Whatever editor you use: http://yihui.name/knitr/demo/editors/

>
> @Duncan: thanks for indicating the use of cat() instead of print(). However, due to the bug in Sweave pointed out by Yihui, replacing print by cat didn't help me.
>
> Thanks
> David


Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



More information about the R-help mailing list