How to create a sweave document without a corner bracket ">" in front of pieces of code?
How can I create a Sweave document (or pgfSweave) without the angle brackets ">" before the code snippets? I want people to be able to cut and paste my code directly from PDF output. Here is a snippet of my document with a snippet of code:
Note that since our incident matrix consists of 0s and 1s, off-diagonal entries represent the total number of common columns that we wanted. Well use the% *% operator to say R for this. Let's first look at a small example, using data about the toys of the people and groups to which they belong. Copy the data into the incidence matrix well using the table () function, then multiply the incidence matrix by its transposition to get the number of common groups between people.
>\> ToyDat <- data.frame(person = c("Sam", "Sam", "Sam", "Greg", "Tom", "Tom"), group = c("a", "b", "c", "a", "b", "c"), stringsAsFactors = F) >\> ToyDatM <- as.matrix(table(ToyDat)) >\> ToyDatM But I want the code to look like this:
> ToyDat <- data.frame(person = c("Sam", "Sam", "Sam", "Greg", "Tom", "Tom"), group = c("a", "b", "c", "a", "b", "c"), stringsAsFactors = F) > ToyDatM <- as.matrix(table(ToyDat)) > ToyDatM I think options(prompt = " ") at the top of your script will do this.
prompt (in options() ) controls the text string used for the invitation in an interactive session, and I assume that it will do the same for the document processed through Sweave.
EDIT: Thanks to Ben Bolker for the fact that options(prompt = " ", continue = " ") also take care of the "+" problem.
Perhaps the best strategy is to provide the Stangle result in your Rnw file - it will contain commands of the entire document, like a script, which can be sent to R or cut-paste into an R session.