I have already replied directly to you on this (in error) but to keep the help within the list I have repeated my answers here and added some information:

If I convert the SWeave Scrap environment to Lyx Code, it compiles (as a bit of text) to PDF as expected, no strange escape codes.

library (car)

So it seems to be definitely connected with the Sweave part of the process

The rest of my reply is below

Philippe Grosjean wrote:
1) Have you placed your code in an ERT (Tex code)?
No, I have now got a twelve chunks of Sweave code in the document (which all work) and none are in ERT

2) Did you enclose it with the required tags for noweb (INSIDE de ERT), i.e.,

library (car)
Yes, the full code copied from Lyx is (its in the Scrap environment and I have added the +'s to make it fit the email):

cabbages$Year<-recode(cabbages$Year,'"X2001"="2001";"X2002"="2002";"X2003"="2003";"X2004"="2004"; +"X2005"="2005";"X2006"="2006";"X2007"="2007";"X2008"="2008";"X2009"="2009";"X2010"="2010";

3) Did you run Sweave on the Noweb version produced?
Not manually in any way, I have just compiled to PDF from Lyx as I have been doing successfully with all the other SWeave chunks, up until this one.

But I haven't called an R package before, or used the recode function. Which are functioning in R OK, as I try the code in R first before copying into Lyx.

Strangely of course, it is compiling OK and giving me a PDF. With the other chunks of code, if I made a mistake, it refused to compile and I got an Rcmd error.

Not sure if that gives any more of a clue.


Reply via email to