[R] write file to date-stamped folder

(Ted Harding) Ted.Harding at manchester.ac.uk
Mon Aug 31 15:42:53 CEST 2009


On 31-Aug-09 13:18:38, Henrique Dallazuanna wrote:
> Try this:
> write.table(test.table, file.path(outputDir, "test.table.txt"),
> sep="\t")

That may not work (depending on the platform OS) if the directory
'outputDir' does not already exist (it will not work on Linux).

In that case, first:

  system(paste("mkdir",outputDir))

Then Henrique's suggestion should work (untested), or simply the
bare-hands construction (tested!):

  write.table(test.table,
              paste(outputDir,"/","test.table.txt",sep=""),
              sep="\t")

Ted.

> On Mon, Aug 31, 2009 at 4:45 AM, suzylee <c.meyer at sms.ed.ac.uk> wrote:
> 
>>
>> Hello,
>>
>> I would like to be able to write all files produced on one day to an
>> output
>> directory with that date stamp, or alternatively stamp the date in the
>> filename. So that if i run the same code the next day the files will
>> not be
>> overwritten.
>>
>> here's what i have to start with:
>> baseDir = getwd()
>> outputDir = paste(baseDir,"/OutputData-", Sys.Date(),sep="")
>>
>> and lets say i want to write the table "test.table" to a file:
>>
>> write.table(test.table, "test.table.txt", sep="\t")
>>
>> How do i make this write to outputDir?
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/write-file-to-date-stamped-folder-tp25219504p2521
>> 9504.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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.
>>
> 
> 
> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
>       [[alternative HTML version deleted]]
> 

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 31-Aug-09                                       Time: 14:42:51
------------------------------ XFMail ------------------------------




More information about the R-help mailing list