I’m following Gregor Gorjanc’s tutorial on LyX & Sweave. Using Ubuntu 10.04 and LyX version 1.6.5 with all of texlive-full installed.
R scraps which result in numerical output produce a valid PDF.
But, when I try to compile simple figures like
<<chunk, fig=T>>= [ctrl+enter]
hist(rnorm(100)) [ctrl+enter]
@
I get cryptic errors. Either that chunk.temp.Rnw wasn’t found, or that LaTeX encountered an error and I should hit <enter> to ignore.
If I change fig to figure and T to TRUE, then the LyX document compiles but displays no graphics. With pgfsweave I get this error, or sometimes this one.
Am I working with the wrong versions of these programs? Is there a way to elicit better error messages? Can I somehow dive into the LaTeX prompt and hit <enter> myself?
update: I was using the wrong version of LaTeX; Ubuntu’s default is too old. Also I needed to update to LyX 2.0.1 and a newer version of pgf and pgfSweave (the programs are distinct).
The new (nondescript) error message is: An error occurred while running: Rscript '/home/mars/.lyx/scripts/lyx-sweave-exec.R' 'UTF-8' 'pgfSweave' "/home/mars/" "/tmp/lyx_tmpdir.T1663/lyx_tmpbuf2/" "test.sweave.lyx.Rnw" > "test.sweave.Rnw".log 2>&1
According to https://tex.stackexchange.com/questions/27993/can-i-download-ctan-packages-from-the-command-line-ubuntu/27994#27994 there is a perennial problem with
TeXin Ubuntu: their packages are way behind. Since many innovations withSweavehave happened in 2010-2011, it seems one must download and install an.isofrom http://ftp.ctex.org/mirrors/CTAN/systems/texlive/Images/ rather than useSynaptic. So much for package management!I’ll accept my own answer only if this actually works.
update: Make sure you disregard anything you read about Noweb.sty because in
LyX 2.0.1there is a “Sweave Module” meaning you should just use regular document classes (article,book,report) — thescrapsare replaced bychunksand essentiallySweaveis handled natively. Also disregard Brett Collier’s lucid explanation of how to installLyXbecause it’s now outdated, despite Gregor Gorjanc’s highly-googleable blog post saying it works. That is also outdated, or maybe it only works in Ubuntu 9 and not Ubuntu 10.04.So the steps to successfully getting
Sweaveto work inLyXfor Ubuntu 10.04 as of August 2011 are:texlivefrom tug.org — not the one from Synaptic. How to do that: https://tex.stackexchange.com/questions/27993/can-i-download-ctan-packages-from-the-command-line-ubuntu/27994pgfandkTikzas described here: http://justbloodywork.blogspot.com/2011/07/installing-latex-and-pgf.htmllyx-develfrom source, apply Yihue’s patch, and configure some LyX preferences.Tools > ReconfigureLyX.LyXand load Yihue’s test file from (3). HitCtrl + R, notCtrl + Dto view.