[R] Rearranging dataset
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Oct 11 08:59:28 CEST 2007
Dieter Menne wrote:
> Megh Dal <megh700004 <at> yahoo.com> writes:
>
>
>> Hi all, I have a datasei like this :
>>
>> ID Date Price
>> aa 01/01/07 12
>> aa 01/02/07 13
>> bb 01/01/07 23
>> bb 01/02/07 12
>>
>>
>> Now I want to write them in following format :
>>
>> ID Date Price ID Date Price
>> aa 01/01/07 12 bb 01/01/07 23
>> aa 01/02/07 13 bb 01/02/07 12
>>
>> Is there any way to do this by some automated way?
>>
>
> The closest guess is to use reshape(... direction= "wide"). Be warned, reshape
> is powerful and has a somewhat complex syntax. The alternative is to use the
> package reshape by Hadley Wickham.
>
>
I understand this as a printing problem, not an issue of actually
modifying the dataframe. If so, you might print each of the two halves
to a character vector by sink()'ing to a text connection, then use
paste() and cat() for the printing.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list