On Mon, Dec 7, 2009 at 9:53 AM, Christophe Genolini
<cgeno...@u-paris10.fr>wrote:

> Hi all,
>
> In the package rtlu, I use the function savePlot. It is convenient since it
> let the user decide in which graphic format he wants his graph to be export.
> But when I run R CMD check, I get the following message :
>
>   rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to
>>
> 3}",graphName="V1")
> Error in savePlot(filename = nomBarplot, type = type) : can only copy from
> 'windows' devices
> Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
> Execution halted
>
> I guess this is a compatibility problem with Linux/Mac? Is there something
> close to savePlot for Mac / Linux?
>
> Christophe
>
>

I'm not sure I understand exactly what you want, but for easy changing of
the output file type,
I've written this small function. Perhaps it can be of help.

Regards,
Gustaf

-----------------------------------------


###Function by Gustaf Rydevik, 2009-12-03 gustaf.ryde...@gmail.com
## Created to facilitate easy changes in the file format of generated
graphs.
## Gen.device() generates a device function that is a copy of an existing
function, but
## with (possibly) new defaults.
## Wanted.device can be the name of any device you choose:
png(),jpeg(),postcript(),etc.
## if fileEnding is missing, the function uses the Wanted.device name as
file ending.
## I then use My.device in the rest of the script file, meaning that I only
have to change file ##format in one location  (in the argument of
Gen.device()) to do so for all susequent graphs.

Gen.device<-function(Wanted.device="png",fileEnding=NULL,...){
    dots<-list(...)
    ending<-Wanted.device
    Wanted.device<-get(Wanted.device)
    if(!is.null(fileEnding)) ending<-fileEnding
        generated.device<-function(File,...){
        dots2<-list(...)
        File<-paste(File,ending,sep=".")
        dots[which(names(dots)%in%names(dots2))]<-NULL
        do.call(Wanted.device,c(filename=File,dots,dots2))
    }
    return(generated.device)
}


##example
My.device<-Gen.device("png",width=7,height=7,units="in",res=Res<-200)
My.device(File="test")
plot(rnorm(1999))
dev.off()




-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to