[R] paste with a matrix
Martyn Plummer
plummer at iarc.fr
Wed Jan 26 16:39:41 CET 2000
On 26-Jan-00 Jens Oehlschlägel-Akiyoshi wrote:
> Hi,
>
> below is a function which pastes a matrix, but uses parsing
> (deparse(substitute()) and eval()).
> Does anyone know a more standard solution to pasting a matrix?
Use apply:
R> dd <- data.frame(code=c(1:3), label=letters[1:3])
R> apply(dd, 1, paste, collapse=" ")
1 2 3
"1 a" "2 b" "3 c"
R> apply(dd, 2, paste, collapse=" ")
code label
"1 2 3" "a b c"
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list