[R] Fwd: Converting R to Sweave (Rnw)

Rainer M Krug r.m.krug at gmail.com
Mon Mar 2 15:06:05 CET 2009


Hi

I am thinking about using Sweave more frequently, especially for
documenting code. But the syntax is slightly awkward for me (<<name>>=
... @), and I was thinking if there would be a way of importing the
type of code extracted from an Rnw file back into an Rnw file? The
advantage would be that the code could run in R without tangling.
Obviously, sweave options could not be imported, but that would be
fine for me. Below an example of the code generated by Rtangle, which
I would like to import into a sweave file.

Cheers

Rainer

###################################################
### chunk number 1: a
###################################################
x <- 10



###################################################
### chunk number 2:
###################################################
asequence<- seq(from=0,to=5,by=0.1)
expnegx2 <- exp(-asequence^2)

plot(asequence,expnegx2,type="l",ylab=expression(exp(-z^2)),xlab="z")


###################################################
### chunk number 3: Normal1
###################################################
mu <- 3
sigma <- 5

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Faculty of Science
Natural Sciences Building
Private Bag X1
University of Stellenbosch
Matieland 7602
South Africa




More information about the R-help mailing list