Try this:

m <- as.data.frame(m)
m.new <- sapply(split(m, m$V2), function(x)paste(x$V1, collapse="|"))

On Mon, Jun 23, 2008 at 10:10 AM, Daren Tan <daren76@hotmail.com> wrote:

>
>
> I tried aggregate, apply etc, but can't get the right result.
>
> For example,
>
> m <- cbind(c(LETTERS[1:5]), c("aa", "bb", "cc", "aa", "cc"))     [,1]
> [,2][1,] "A"  "aa"[2,] "B"  "bb"[3,] "C"  "cc"[4,] "D"  "aa"[5,] "E"  "cc"
> how to obtain m.new where "aa", "bb", and "cc" are groups, and more than
> one values "A" to "E" belonging to the same group are separated by "|"
>       [,1] [,2][1,] "aa"  "A|D"[2,] "bb"  "B"[3,] "cc"  "C|E"
>
>
> _________________________________________________________________
> Easily edit your photos like a pro with Photo Gallery.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

