On Thu, May 10, 2018 at 11:50:37AM +0000, Jean-Marc Lasgouttes wrote: > Le 05/05/2018 à 23:26, Scott Kostyshak a écrit : > > The reason for this error, from the R perspective, is detailed by this > > r-help ML post [1]. The problem is that when LyX exports the .Rnw file > > (which in turn is used to make the .R file), the .Rnw file is created > > with encoding "iso-8859-1". I think that this encoding is consistent > > with the encoding that we set for creating .tex files that we export (if > > they contain e.g. an "á" character, as is contained in the attached .lyx > > file). However, R does not interpret files in the same way as LaTeX > > engines do. It seems that LaTeX engines automatically handle .tex files > > of various encodings. R, by default, assumes a certain encoding (which > > encoding it assumes depends on the output of Sys.getlocale()). For my > > system, it appears that UTF-8 is assumed. > > Our helper scripts lyxtangle.R/lyxsweave.R and friends set the correct > encoding before running R. > > What is your use case here? Knowing this would help to do things right. We > could always add the explicit encoding setting at the start of the R file, > but I suspect that this could lead to other issues.
I often export only the R code when there is an error, so that I can debug. So if I run it in LyX and I get an error and it is not obvious to me where the problem is, I export to R code, then I run source("file.R", echo = TRUE) Then I usually do debugger() after I run into an error. Also, sometimes I need to send my code to coauthors who do not use LyX. Scott
signature.asc
Description: PGP signature