julia.jacobson at arcor.de
2012-May-04 15:23 UTC
[R] [Sweave] string.prefix without hyphen-minus
Dear Sweave users, Could you help me to find a way to place Sweave output files in a subdirectory of the currentfolder without giving them a subname? If the option "prefix.string=foo/" is used, all files are placed in this folder, but begin with an hyphen-minus, which makes it difficult to work with them. If the option "prefix=FALSE" is used, then files won't be placed in a subdirectory. Thanks in advance for your help, Julia
I guess that is hard-coded in Sweave, so you probably cannot control it unless you (partially) rewrite the driver. And just FYI, you can try the knitr package, which does not add the hyphen for you, but the name of the option 'prefix.string' has been changed to 'fig.path' (http://yihui.name/knitr/options). If you set fig.path='foo/', figures will be generated as, e.g., foo/label.pdf instead of foo/-label.pdf utils::RweaveChunkPrefix function (options) { if (!is.null(options$label)) { if (options$prefix) chunkprefix <- paste(options$prefix.string, "-", options$label, sep = "") else chunkprefix <- options$label } else chunkprefix <- paste(options$prefix.string, "-", formatC(options$chunknr, flag = "0", width = 3), sep = "") chunkprefix } Regards, Yihui -- 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 On Fri, May 4, 2012 at 10:23 AM, <julia.jacobson at arcor.de> wrote:> Dear Sweave users, > > Could you help me to find a way to place Sweave output files in a subdirectory of the currentfolder without giving them a subname? > If the option "prefix.string=foo/" is used, all files are placed in this folder, but begin with an hyphen-minus, which makes it difficult to work with them. If the option "prefix=FALSE" is used, then files won't be placed in a subdirectory. > > Thanks in advance for your help, > Julia >
You cannot avoid the hyphen I think, but if you say (for example): "prefix.string=foo/x" then your files start with 'x-' (so 'graph' becomes 'foo/x-graph') which may be better for you than the hyphen at the beginning of the file name. Rgds, Rainer On Friday 04 May 2012 17:23:58 julia.jacobson at arcor.de wrote:> Dear Sweave users, > > Could you help me to find a way to place Sweave output files in a subdirectory of the currentfolder without giving them a subname? > If the option "prefix.string=foo/" is used, all files are placed in this folder, but begin with an hyphen-minus, which makes it difficult to work with them. If the option "prefix=FALSE" is used, then files won't be placed in a subdirectory. > > Thanks in advance for your help, > Julia > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.