[R] Rearranging a data frame for multiple observations
Henrique Dallazuanna
wwwhsd at gmail.com
Sat Feb 20 16:37:39 CET 2010
Try this:
do.call(rbind, lapply(unstack(x, V2 ~ V1), '[', 1:max(with(x,
tapply(V2, V1, length)))))
On Sat, Feb 20, 2010 at 9:26 AM, Newbie19_02 <nvanzuydam at gmail.com> wrote:
>
> Hi there,
>
> I think I'm struggling with a fairly simple problem but can't seem to solve
> it. I have multiple observations for one unique identifier. Ultimately I
> want to end up with one line per identifier with multiple observations in
> rows. I'm really stuck any help would be really appreciated.
>
>
> CAO0337134 05/09/95
> CAO0337134 27/09/05
> CAO0347741 10/10/04
> CAO0347741 12/10/04
> CAO0367128 11/07/05
> CAO0367128 12/07/05
> CAO0367128 14/07/05
> CAO0367128 19/09/97
> CAO0367128 20/09/97
> CAO0374110 14/11/89
> CAO0374110 17/11/89
> CAO0374779 01/10/99
> CAO0374779 28/09/99
> CAO0374779 29/09/99
>
> Thanks
> Natalie
> --
> View this message in context: http://n4.nabble.com/Rearranging-a-data-frame-for-multiple-observations-tp1562780p1562780.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list