write
Write Data to ASCII File

Description

Writes the contents of the data, in ASCII format, to the specified file.

Usage

write(x, file = "data", ncolumns = <<see below>>, append = FALSE, 
    sep = " ")

Arguments

x a vector. Missing values (NAs) are allowed.
file a character string naming the file where you want to write the data. On Windows, if file is "clipboard" the data are written to the Windows clipboard instead of to a file.
ncolumns the number of data items to put on each line of file. The default is 5 per line for numeric data, and 1 per line for character data.
append a logical value. If FALSE (the default), creates the file or overwrites the contents of the specified existing file. If TRUE, appends the data to any contents extant in file.
sep the separator to use between data items. The default is a space: " ".

Details

Because of the way matrix data are stored, matrices are written in column-by-column order. The result is equivalent to a vector: the ncolumns argument states the user preference and is unrelated to the dimensions of the matrix.
Side Effects
the specified file is created or appended with the contents of data.
See Also
dput, dump, scan, cat.
Examples
filex <- tempfile("filex")
x <- runif(8)
write(round(x, 3), filex)

# write matrix row by row x.byrows <- tempfile("x.byrows") x <- matrix(1:12,4) write(t(x), file=x.byrows, ncolumns=ncol(x))

unlink(c(filex, x.byrows)) # clean up

Package base version 6.1.1-7
Package Index