[R] Exporting PDF

Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polwart at nhs.net
Tue Apr 20 21:37:50 CEST 2010


> I run the script and it exports a PDF called "version 1".
> I want it to check if "version 1" already exists. If so,
>  then I want the new graphs to be exported as
> "version 2", and so on.
>
> Is it possible to do it in R?

Someone may know a way.  However its certainly possible to execute a command in linus from R.  So you can ls the file (in windows try dir) and see if it exists, and build a loop round that.
Just bew3are it'll be quick if there is only 1 file.  If you have 9999 files it may slow things down a bit!
Here's my example...

#Example script to check if a file exists (linux system)
filename = "somefile"
fileno = 0
extension= ".pdf"
path="/home/user/"

repeat
{
        fullfile= paste(path,filename,fileno,extension, sep="")
        if (length (system(paste("ls",fullfile), intern = T)) == 0) break
        fileno<-fileno+1
}

#your command to save the file... using 'fullfile' as the filename and path


********************************************************************************************************************

This message may contain confidential information. If yo...{{dropped:21}}



More information about the R-help mailing list