Re: [Rd] Sweave: multiple graphic formats, e.g. win.metafile

2011-03-23 Thread Greg Snow
You might consider using odfWeave, then you can create a single document, save 
it as a word doc, and send it to collaborators where they can then cut and 
paste from the word doc to whatever they are using.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-devel-boun...@r-project.org [mailto:r-devel-bounces@r-
> project.org] On Behalf Of Meyer, Sebastian
> Sent: Wednesday, March 23, 2011 5:08 AM
> To: 'r-devel@r-project.org'
> Cc: 'friedrich.lei...@lmu.de'
> Subject: [Rd] Sweave: multiple graphic formats, e.g. win.metafile
> 
> Dear R devel,
> 
> being constrained to a windows environment at work and having
> colleagues being accustomed to the Microsoft Office Suite, I was
> looking for a way to have the RweaveLatex driver for Sweave
> automatically generating 'win.metafile's in addition to the pdf
> graphics.
> Without this functionalilty, the generation of emf-graphics is quite
> laborious, I think:
> 
> <<>>=
> plotit <- function () {
># code which generates the graphic
> }
> win.metafile("foobar.emf")
> plotit()
> dev.off()
> pdf("foobar.pdf")
> plotit()
> dev.off()
> @
> \includegraphics{foobar}
> 
> 
> I would like to have something like:
> 
> <>
> # code which generates the graphic
> @
> 
> 
> SweaveHooks are not applicable for this feature. Therefore, I thought
> it would be best to extend the typical 'RweaveLatex' driver by an
> option 'emf' - like eps and pdf. So, here is the result of some
> handicrafts:
> 
> RweaveLatexEMF <- function ()
> {
>   # add option emf (= FALSE) and set default for eps to FALSE
>   setup <- utils::RweaveLatexSetup
>   setupsrc <- deparse(setup)
>   epsline <- grep("eps", setupsrc)
>   setupsrc[epsline] <- sub("eps = TRUE", "eps = FALSE, emf =
> FALSE", setupsrc[epsline])
>   setup <- eval(parse(text=setupsrc))
> 
>   # 'makeRweaveLatexCodeRunner' function
>   makeruncode <- function(evalFunc=utils::RweaveEvalWithOpt) {
>   runcode <- utils:::RweaveLatexRuncode
>   runcodesrc <- deparse(runcode)
>   epsline1 <- grep("cat(.. eps..)", runcodesrc)
>   runcodesrc <- append(runcodesrc, "if
> (options$emf) cat(\" emf\")", after=epsline1)
>   epsline2 <- grep("options\\$fig && options\\$eval",
> runcodesrc)
>   runcodesrc <- append(runcodesrc,
>   deparse(quote(
>   if (options$emf && .Platform$OS.type ==
> "windows") {
>   grDevices::win.metafile(file=paste(chunkprefix,
> "emf", sep="."),
> 
> width=options$width, height=options$height)
>   err <- try({SweaveHooks(options, run=TRUE)
>   eval(chunkexps, envir=.GlobalEnv)})
>   grDevices::dev.off()
>   if(inherits(err, "try-error")) stop(err)
>   }
>   ))
>   , after=epsline2)
>   runcode <- eval(parse(text=runcodesrc))
>   }
>   runcode <- makeruncode()
> 
>   list(setup = setup, runcode = runcode,
> writedoc = utils::RweaveLatexWritedoc, finish =
> utils::RweaveLatexFinish,
> checkopts = utils::RweaveLatexOptions)
> }
> 
> 
> This enhanced Sweave driver works for me like a charm, but it is a very
> poor solution.
> What about allowing for all available grDevices on the current platform
> - besides the standard eps and pdf devices? The only building block is
> the section "if (options$fig && options$eval)" in
> utils:::makeRweaveLatexCodeRunner. The TODO list of Seth Falcon's
> weaver package also states "For Sweave: multiple graphic formats
> besides just pdf and eps (perhaps
> as a separate driver?)".
> However, since so many packages depend on the basic Sweave
> implementation by Fritz Leisch, I don't know if there is an easy route
> to tackle.
> 
> Looking forward to your opinions and pointers.
> Best regards,
>   Sebastian Meyer
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Sweave: multiple graphic formats, e.g. win.metafile

2011-03-23 Thread Claudia Beleites

On 03/23/2011 01:05 PM, Prof Brian Ripley wrote:

We are currently in the process of implementing PNG and JPEG for 2.13.0, and an
extensible architecture is planned for 2.14.0.

:-) this is really good news :-)


Thank you!


--
Claudia Beleites
DI3
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Sweave: multiple graphic formats, e.g. win.metafile

2011-03-23 Thread Prof Brian Ripley
We are currently in the process of implementing PNG and JPEG for 
2.13.0, and an extensible architecture is planned for 2.14.0.


On Wed, 23 Mar 2011, Meyer, Sebastian wrote:


Dear R devel,

being constrained to a windows environment at work and having colleagues being 
accustomed to the Microsoft Office Suite, I was looking for a way to have the 
RweaveLatex driver for Sweave automatically generating 'win.metafile's in 
addition to the pdf graphics.
Without this functionalilty, the generation of emf-graphics is quite laborious, 
I think:

<<>>=
plotit <- function () {
  # code which generates the graphic
}
win.metafile("foobar.emf")
plotit()
dev.off()
pdf("foobar.pdf")
plotit()
dev.off()
@
\includegraphics{foobar}


I would like to have something like:

<>
# code which generates the graphic
@


SweaveHooks are not applicable for this feature. Therefore, I thought it would 
be best to extend the typical 'RweaveLatex' driver by an option 'emf' - like 
eps and pdf. So, here is the result of some handicrafts:

RweaveLatexEMF <- function ()
{
# add option emf (= FALSE) and set default for eps to FALSE
setup <- utils::RweaveLatexSetup
setupsrc <- deparse(setup)
epsline <- grep("eps", setupsrc)
setupsrc[epsline] <- sub("eps = TRUE", "eps = FALSE, emf = FALSE", 
setupsrc[epsline])
setup <- eval(parse(text=setupsrc))

# 'makeRweaveLatexCodeRunner' function
makeruncode <- function(evalFunc=utils::RweaveEvalWithOpt) {
runcode <- utils:::RweaveLatexRuncode
runcodesrc <- deparse(runcode)
epsline1 <- grep("cat(.. eps..)", runcodesrc)
runcodesrc <- append(runcodesrc, "if (options$emf) cat(\" 
emf\")", after=epsline1)
epsline2 <- grep("options\\$fig && options\\$eval", runcodesrc)
runcodesrc <- append(runcodesrc,
deparse(quote(
if (options$emf && .Platform$OS.type == 
"windows") {
grDevices::win.metafile(file=paste(chunkprefix, "emf", 
sep="."),

width=options$width, height=options$height)
err <- try({SweaveHooks(options, run=TRUE)
eval(chunkexps, envir=.GlobalEnv)})
grDevices::dev.off()
if(inherits(err, "try-error")) stop(err)
}
))
, after=epsline2)
runcode <- eval(parse(text=runcodesrc))
}
runcode <- makeruncode()

list(setup = setup, runcode = runcode,
   writedoc = utils::RweaveLatexWritedoc, finish = utils::RweaveLatexFinish,
   checkopts = utils::RweaveLatexOptions)
}


This enhanced Sweave driver works for me like a charm, but it is a very poor 
solution.
What about allowing for all available grDevices on the current platform - besides the standard eps and 
pdf devices? The only building block is the section "if (options$fig && 
options$eval)" in utils:::makeRweaveLatexCodeRunner. The TODO list of Seth Falcon's weaver 
package also states "For Sweave: multiple graphic formats besides just pdf and eps (perhaps
as a separate driver?)".
However, since so many packages depend on the basic Sweave implementation by 
Fritz Leisch, I don't know if there is an easy route to tackle.

Looking forward to your opinions and pointers.
Best regards,
 Sebastian Meyer

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Sweave: multiple graphic formats, e.g. win.metafile

2011-03-23 Thread Meyer, Sebastian
Dear R devel,

being constrained to a windows environment at work and having colleagues being 
accustomed to the Microsoft Office Suite, I was looking for a way to have the 
RweaveLatex driver for Sweave automatically generating 'win.metafile's in 
addition to the pdf graphics.
Without this functionalilty, the generation of emf-graphics is quite laborious, 
I think:

<<>>=
plotit <- function () {
   # code which generates the graphic
}
win.metafile("foobar.emf")
plotit()
dev.off()
pdf("foobar.pdf")
plotit()
dev.off()
@
\includegraphics{foobar}


I would like to have something like:

<>
# code which generates the graphic
@


SweaveHooks are not applicable for this feature. Therefore, I thought it would 
be best to extend the typical 'RweaveLatex' driver by an option 'emf' - like 
eps and pdf. So, here is the result of some handicrafts:

RweaveLatexEMF <- function ()
{
# add option emf (= FALSE) and set default for eps to FALSE
setup <- utils::RweaveLatexSetup
setupsrc <- deparse(setup)
epsline <- grep("eps", setupsrc)
setupsrc[epsline] <- sub("eps = TRUE", "eps = FALSE, emf = FALSE", 
setupsrc[epsline])
setup <- eval(parse(text=setupsrc))

# 'makeRweaveLatexCodeRunner' function
makeruncode <- function(evalFunc=utils::RweaveEvalWithOpt) {
runcode <- utils:::RweaveLatexRuncode
runcodesrc <- deparse(runcode)
epsline1 <- grep("cat(.. eps..)", runcodesrc)
runcodesrc <- append(runcodesrc, "if (options$emf) 
cat(\" emf\")", after=epsline1)
epsline2 <- grep("options\\$fig && options\\$eval", runcodesrc)
runcodesrc <- append(runcodesrc, 
deparse(quote(
if (options$emf && .Platform$OS.type == 
"windows") {
grDevices::win.metafile(file=paste(chunkprefix, 
"emf", sep="."),

width=options$width, height=options$height)
err <- try({SweaveHooks(options, run=TRUE)
eval(chunkexps, envir=.GlobalEnv)})
grDevices::dev.off()
if(inherits(err, "try-error")) stop(err)
}
))
, after=epsline2)
runcode <- eval(parse(text=runcodesrc))
}
runcode <- makeruncode()

list(setup = setup, runcode = runcode, 
writedoc = utils::RweaveLatexWritedoc, finish = 
utils::RweaveLatexFinish, 
checkopts = utils::RweaveLatexOptions)
}


This enhanced Sweave driver works for me like a charm, but it is a very poor 
solution.
What about allowing for all available grDevices on the current platform - 
besides the standard eps and pdf devices? The only building block is the 
section "if (options$fig && options$eval)" in 
utils:::makeRweaveLatexCodeRunner. The TODO list of Seth Falcon's weaver 
package also states "For Sweave: multiple graphic formats besides just pdf and 
eps (perhaps
as a separate driver?)".
However, since so many packages depend on the basic Sweave implementation by 
Fritz Leisch, I don't know if there is an easy route to tackle.

Looking forward to your opinions and pointers.
Best regards,
  Sebastian Meyer

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel