More simple: aggregate(x$ZIP_CODE, list(CODE_NAME = x$CODE_NAME), paste, collapse = ",")
On Tue, Dec 23, 2008 at 3:27 PM, Henrique Dallazuanna <www...@gmail.com>wrote: > Try this: > > do.call(rbind, > lapply(split(x, x$CODE_NAME), > function(cod) > data.frame(CODE_NAME = > unique(cod$CODE_NAME), > ZIP_CODE = > paste(cod$ZIP_CODE, collapse = ",")) > ) > ) > > > > On Tue, Dec 23, 2008 at 3:10 PM, Ferry <fmi.ml...@gmail.com> wrote: > >> Dear R-Users, >> >> Suppose I have data in the following format: >> >> CODE_NAME ZIP_CODE >> John 12345 >> John 23456 >> John 34567 >> Jane 13242 >> Jane 22123 >> >> I want to transpose / convert it into: >> CODE_NAME ZIP_CODE >> John 12345,23456,34567 >> Jane 13242,22123 >> >> Any idea/pointer is appreciated. >> >> Thanks a bunch, >> >> Ferry >> >> [[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 > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.