[Rd] Sweave and absolute escaped backslashed Windows paths in R 2.12.0

Duncan Murdoch murdoch.duncan at gmail.com
Tue Oct 26 02:18:41 CEST 2010


On 25/10/2010 6:24 PM, Duncan Murdoch wrote:
> Brian Diggs wrote:
>> I've noticed a change in behavior in R 2.12.0 from 2.11.1 regarding the
>> treatment of absolute paths in the file argument of Sweave in a Windows
>> environment.
>
> Looks like a bug to me, probably related to the new error reporting.

It was a bug, now fixed in R-devel and R-patched (as of r53428).

Duncan Murdoch

>
> Duncan Murdoch
>
>>
>> Consider the minimal Rnw file, attached and reproduced below my
>> signature in case .Rnw files get stripped.  This file is stored on my
>> (Windows) computer in H:/My Documents.  Using an absolute path with the
>> standard window's escaped backslahes path gives an error:
>>
>>   >  Sweave("H:\\My Documents\\test.Rnw")
>> Writing to file test.tex
>> Processing code chunks ...
>>    1 : echo term verbatim
>>
>> Error:  chunk 1
>> Error : '\M' is an unrecognized escape in character string starting "H:\M"
>>
>> Nothing in the chuck explicitly references the path, but something
>> Sweave does triggers this.  This did not happen in 2.11.1.  Specifying
>> the path using slashes or as a relative path works.
>>
>>   >  Sweave("H:/My Documents/test.Rnw")
>> Writing to file test.tex
>> Processing code chunks ...
>>    1 : echo term verbatim
>>
>> You can now run LaTeX on 'test.tex'
>>   >  Sweave("test.Rnw")
>> Writing to file test.tex
>> Processing code chunks ...
>>    1 : echo term verbatim
>>
>> You can now run LaTeX on 'test.tex'
>>
>> I discovered this problem from a feature ESS has which has a keybinding
>> that executes Sweave using the command:
>>
>>   >  local({..od<- getwd(); setwd("h:\\My Documents\\"); Sweave("h:\\My
>> Documents\\test.Rnw"); setwd(..od) })
>> Writing to file test.tex
>> Processing code chunks ...
>>    1 : echo term verbatim
>>
>> Error:  chunk 1
>> Error : '\M' is an unrecognized escape in character string starting "h:\M"
>>
>> I can certainly work around it by manually executing Sweave with slashed
>> or relative paths, but it is an inconvient change in behavior that I
>> don't recall seeing a reference to in NEWS.
>>
>> I'm guessing something in Sweave is taking the string
>> "H:\\My Documents\\test.Rnw"
>> and turning it into
>> "H:\My Documents\test.Rnw"
>> which when treated as a string is not valid (as \M is not a valid
>> escape).  However, I don't know what is doing this.  Could it be related
>> to the ability to give context sensitive errors ("Parsing errors
>> detected during Sweave() processing will now be reported referencing
>> their original location in the source file.") which is new in 2.12.0?
>>
>>   >  sessionInfo()
>> R version 2.12.0 (2010-10-15)
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252
>> [2] LC_CTYPE=English_United States.1252
>> [3] LC_MONETARY=English_United States.1252
>> [4] LC_NUMERIC=C
>> [5] LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list