[R] Reorganize data fram

Dennis Murphy djmuser at gmail.com
Tue Jul 12 16:33:13 CEST 2011


Hi:

Try the cast() function in the reshape package. Using d as the name of
your data frame,

library(reshape)
cast(d, Date ~ Category, value = 'Temperature')
     Date  A  B  C
1 2007102 16 17 18

HTH,
Dennis


On Tue, Jul 12, 2011 at 5:42 AM, anglor <angelica.ekenstam at dpes.gu.se> wrote:
> Hi,
>
> I have a data frame of about 700 000 rows which look something like this:
>
> Date        Temperature  Category
> 2007102   16                   A
> 2007102   17                   B
> 2007102   18                   C
>
> but need it to be:
>
> Date          TemperatureA  TemperatureB   TemperatureC
> 2007102       16                 17                    18
>
> Any suggestions?
>
> /Angelica
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Reorganize-data-fram-tp3662123p3662123.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.
>



More information about the R-help mailing list