Write a Matrix or Data Frame
Usage
write.matrix(x, file="", sep=" ")
Arguments
x
|
matrix or data frame.
|
file
|
name of output file. The default ("" ) is the terminal.
|
sep
|
The separator between columns.
|
Description
Writes a matrix or data frame to a file or the terminal, using column
labels and a layout respecting columns.Value
noneSide Effects
A formatted file is produced, with column headings (if x
has them)
and columns of data.See Also
write.table
Examples
# The function is defined as
function(x, file = "", sep = " ")
{
x <- as.matrix(x)
p <- ncol(x)
cat(dimnames(x)[[2]], format(t(x)), file = file,
sep = c(rep(sep, p - 1), "\n"))
}