write.matrix {MASS} | R Documentation |
Writes a matrix or data frame to a file or the terminal, using column labels and a layout respecting columns.
write.matrix(x, file="", sep=" ")
x |
matrix or data frame. |
file |
name of output file. The default ("" ) is the terminal.
|
sep |
The separator between columns. |
none
A formatted file is produced, with column headings (if x
has them)
and columns of data.
# 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")) }