Hi, I think the problem came from the explicit argument "--args" when running Rscript; it should not be there. You can remove it and try again.
Tools-->Preferences-->Converters; find Sweave to LaTeX (whatever); then modify the converter (remove "--args"). The presence of "--args" will make ls.args[4] to be ISO-8859-15, which is obviously not a directory name. Regards, Yihui -- Yihui Xie <xieyi...@gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Tue, Jun 7, 2011 at 6:22 AM, Franz Jimeno <jimenofranci...@uniovi.es> wrote: > Hi, > > I'm using Lyx 2.0 with Windows 7. > When I try to preview the sweave.lyx example I get an error: > > Error in setwd(ls.args[4]) : cannot change working directory > > There is something wrong with the arguments of the script. > > When I try to execute the script on the console: > > Rscript --verbose --no-save --no-restore "C:/Program > Files/LyX20/bin/../Resources/scripts/lyxsweave.R" --args > "C:/Users/Franz/AppData/Local/Temp/lyx_tmpdir.Hp5712/lyx_tmpbuf2/""sweave.Rnw" > "C:/Users/Franz/AppData/Local/Temp/lyx_tmpdir.Hp5712/lyx_tmpbuf2/""sweave.tex" > ISO-8859-15 "C:/Program Files/LyX20/Resources/examples/" > > I get this error: > > Error en setwd(ls.args[4]) : missing value is invalid > > ls.args shows as NA on the script. > > Does anyone have the same problem? > > Franz >