Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I suppress the arrow (">") in the R/S output in Sweave?

Tags:

r

latex

sweave

whenever I run some R code with Sweave, it displays the terminal arrows (">") in the document. This is fine for session inputs, but sometimes I'd like to include custom functions. When arrows show up in the document, it is more difficult to copy and paste important snippets of code. Is there a quick way to do this?

I know I can run the code while suppressing the output all together, and then copy that code into a \Verbatim, but that requires extra typing.

Thanks

dumbo <- function(x)
  2*x

instead of

> dumbo <- function(x)
>   2*x
like image 987
apeescape Avatar asked Nov 10 '10 00:11

apeescape


3 Answers

Just add this to the top of the first chunk:

options(prompt=" ",continue=" ")

You can get back any moment with:

options(prompt="> ",continue="+ ")
like image 154
mbq Avatar answered Oct 08 '22 01:10

mbq


options(prompt=" ")

You can set it back at the end. options(prompt="> ")

like image 39
Maiasaura Avatar answered Oct 08 '22 01:10

Maiasaura


This is off by default in knitr, the "next generation Sweave". Other nice features include syntax coloring and PGF integration.

Sweave code of average complexity needs only minor if any adaptions to run with knitr.

like image 29
krlmlr Avatar answered Oct 08 '22 02:10

krlmlr