Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sweave/r - omit initial `>` in code chunks with `echo=true`?

Tags:

r

sweave

I'm very new to sweave and I feel this will be an easy question, but I'm struggling to solve it myself (googling omit ">" Sweave doesn't really work because I can't search for ">"!).

I'm including a short script into my document:

<<echo=true, results=hide, eval=false>>=
# This is a simple script.
print('Hello World!\n')
@

I basically want the script to appear verbatim in the document, using whatever Sweave's "code" environment is. I don't want to evaluate it - it's just there to demonstrate how one might write a script utilising the functions in the package this document is for.

However, this produces the following in the output document:

> # This is a simple script
> print('Hello World!\n')

Is there some way to omit the > ? Is this the right way to put a script into a Sweave document, or is there some other environment that is meant to be used? (I can use a \begin{verbatim}, but it seemed to me that I should use Sweave commands if possible for code chunks).

I just want the output to be

# This is a simple script.
print('Hello World!\n')
like image 820
mathematical.coffee Avatar asked Apr 27 '26 10:04

mathematical.coffee


1 Answers

You can try changing the prompt and continue options, which define the > and + characters.

options(continue=" ", prompt=" ")
like image 51
Vincent Zoonekynd Avatar answered Apr 29 '26 00:04

Vincent Zoonekynd