Skip to content
Prev 131844 / 398506 Next

Writing a file to the disk

On 11/12/2007 5:13 PM, Thomas L Jones, PhD wrote:
Get the formatted numbers you want in a character vector, then use 
writeLines to write it out.  For example:

x <- rnorm(20)
text <- sprintf("%9.6f", x)
writeLines(text, file.choose())

This will open a file selection directory where you can navigate to the 
correct folder and enter the filename.  Alternatively, you could put the 
whole path to the file in place of file.choose().  As a third choice, 
you could just use "clipboard"; on Windows, this will write the text 
directly into the clipboard, and you can paste from there to your 
spreadsheet.

Duncan Murdoch