\") in the document. This is fine for session inputs, but sometimes I\'d lik开发者_JAVA百科e to include custom functions. Wh" />
开发者

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

开发者 https://www.devze.com 2023-01-24 02:10 出处:网络
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 lik开发者_JAVA百科e to include custom functions. Wh

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 lik开发者_JAVA百科e 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


Just add this to the top of the first chunk:

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

You can get back any moment with:

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


options(prompt=" ")

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消