[Rd] Quote the path of graphics output in Sweave when it contains spaces

From: Yihui Xie <xie_at_yihui.name>
Date: Mon, 20 Jun 2011 16:57:12 -0500


I'm aware of the definition of a "valid filename" in .SweaveValidFilenameRegexp, but I think it might be better to quote the filename when it contains spaces instead of just giving a warning. This should bring us safer LaTeX code (although I never use spaces in paths).

Here is the simple patch:

Index: src/library/utils/R/SweaveDrivers.R

             if (options$include) {
+                if (grepl("[[:space:]]", chunkprefix))
+                    chunkprefix = shQuote(chunkprefix, type = "cmd")
                 cat("\\includegraphics{", chunkprefix, "}\n", sep = "",
                     file = object$output)
                 linesout[thisline + 1L] <- srcline



Yihui Xie <xieyihui_at_gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA

R-devel_at_r-project.org mailing list
Received on Mon 20 Jun 2011 - 21:59:45 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 21 Jun 2011 - 11:40:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive