Not possible at least with typical base R functions. You would need to augment the smaller (or possible both) so that they can be cbind()-ed and then pasted (with tab separators) into Excel. Even getting the operation of copying a stream of characters into the Clipboard that would carry out this operation on one matrix is not trivial. The Ripley-Venables authored MASS package has a write.matrix
function, but it does not write rownames, only column names. This is derivative (omitting the blocking option) function that first adds a blank in the upper left corner and cbinds the rownames before processing. It could be paired with a function that inserted the rownames in the second. Perhaps the cbind.fill
function implemented with
matbound <-cbind.fill(mat1, cbind(rownames(mat2),mat2) )
Followed by this hack of the second portion of the MASS::write.matrix:
write.matrix.clip <-
function (x, file = "", sep = "\t")
{clip <- pipe("pbcopy", "w")
x <- as.matrix(x)
p <- ncol(x)
cn <- c(" ", colnames(x))
cat(c(cn, format(t( cbind(rownames(x),x)))), file = clip, sep = c(rep(sep,
p ), "\n")); close(clip)
}
write.matrix.clip(matbound)
(The clipboard value could be "clipboard" on a windows machine.)