Re: [R] Fastest way to merge matrix columns into a comma delimited string?

From: Sarah Goslee <sarah.goslee_at_gmail.com>
Date: Tue, 15 Jun 2010 15:13:31 -0400

> apply(test, 1, paste, collapse=",")

 [1] "1,2,3" "2,3,1" "3,1,2" "1,2,3" "2,3,1" "3,1,2" "1,2,3" "2,3,1" "3,1,2" [10] "1,2,3"

On Tue, Jun 15, 2010 at 2:27 PM, Jonathan Greenberg <greenberg_at_ucdavis.edu> wrote:
> Folks:
>
> Say I have a matrix:
>
> test=matrix(c(1,2,3),nrow=10,ncol=3)
>
> I would like to have an output character vector where each line is
> row's values delimited by commas, e.g.:
>
> "1,2,3"
> "2,3,1"
> "3,1,2"
> ...
> "1,2,3"
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 15 Jun 2010 - 19:21:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Jun 2010 - 19:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive