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-tp25219504p25219504.html Sent from the R help mailing list archive at Nabble.com.
Try this: write.table(test.table, file.path(outputDir, "test.table.txt"), sep="\t") On Mon, Aug 31, 2009 at 4:45 AM, suzylee <c.meyer@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-tp25219504p25219504.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
How about:> test.table <- matrix ( rnorm ( 25 ) , ncol = 5 ) > outputDir = paste (+ getwd ( ) + , "/OutputData-" + , Sys.Date ( ) + , sep = "" + )> dir.create ( outputDir ) > write.table (+ test.table + , paste ( + outputDir + , "test.table.txt" + , sep = "/" + ) + , sep = "\t" + )>-- David -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of suzylee Sent: Monday, August 31, 2009 3:45 AM To: r-help at r-project.org Subject: [R] write file to date-stamped folder 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-tp25219504p25219 504.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.
Seemingly Similar Threads
- [PATCH 1/2] utils: import parse_size from libguestfs
- [PATCH 0/3] supermin: add --include-packagelist
- [supermin PATCH v2 0/4] Check for output results for --if-newer (RHBZ#1813809)
- [supermin PATCH 0/4] Check for output results for --if-newer (RHBZ#1813809)
- [PATCH 0/3] Miscellaneous improvements to supermin.