Thank you, Nicolás. Also thank Uwe Ligges, Brian D. Ripley, and Paul Johnson for their advices. Here is a summary of the advices about how to make Rweave work in Lyx under Windows:

Suppose your Lyx is installed in C:\ProgramFiles\Lyx and your R in
C:\ProgramFiles\R-2.2.1.

1. Create a R file "MakeSweave.R" with the following lines and then put
it in "C:\ProgramFiles\Lyx\bin\" (this is a path registered in Lyx).

library(tools)
args <- commandArgs()
inp <- args[length(args)]
Sweave(inp)
base <- sub("\.(Rnw|Rtex)$", "", inp)
texi2dvi(paste("base", ".tex", sep=""), pdf=TRUE)
shell.exec(paste("base", ".pdf", sep=""))

2. Create a batch script called "Rweave.bat" with the follwowing line,
and put it in "C:\ProgramFiles\Lyx\bin\". (Note that back slash "/",
rather than slash "/", is used in the script.)
C:/ProgramFiles/R-2.2.1/bin/Rterm --no-save --args "%1"
<C:/ProgramFiles/LyX/bin/MakeSweave.R> "%1.log"

3. Put noweb.sty (can be found in google, or simply grab this file:
http://www.lsi.upc.es/~tpl/noweb.sty) in
C:\ProgramFiles\Miktex\tex\latex\noweb\ and refresh MikTex.

4. Reconfigure Lyx (go to Edit-> Reconfigure). Check if you have
document class "article(noweb)" (Layout->Document), If not, you may need
to reinstall Lyx.

5. Last, make Lyx recognize the converter script Rweave. Go to
Edit->Preferences->Converters. In the "From" pulldown, choose Noweb. In
the "To" pulldown, choose LaTeX. Hit the "new" button toward the bottom.
Then, make sure the Converter Noweb->LaTeX is chosen, and in the box
called "Converter" type "Rweave $$i" without the quotation "".


To test if the installation is done, check out Dr. Paul Johnson's
example file (http://pj.freefaculty.org/stat/Distributions/Gamma-02.lyx
). See if you can view its pdf file.


-Frank Liu

Reply via email to