[R] reshape from wide to long, ordering of "varying"
stefan.duke at gmail.com
stefan.duke at gmail.com
Thu Oct 7 22:42:00 CEST 2010
Thanks a lot! Both solutions work great!
On Thu, Oct 7, 2010 at 7:19 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> On Thu, Oct 7, 2010 at 1:05 PM, stefan.duke at gmail.com
> <stefan.duke at gmail.com> wrote:
>> Hello,
>> I have data in the following form
>>
>> age sex Int.Prev.Est.1 Int.Prev.Est.2 Int.Prev.Est.3
>> Int.Prev.Est.4 Int.Prev.Est.5
>> 93110 93 0 23.75482 57.86592 9.755003
>> 4.343534 4.280714
>> 93610 93 1 53.36475 39.47247 4.381618
>>
>> and want to get it in the form:
>>
>> age sex cat Int.Prev.Est
>> 93 0 1 23.75482
>> 93 0 2 57.86592
>> 93 0 3 9.755003
>> 93 0 4 4.343534
>> (....)
>
> Try this:
>
> reshape(UK.INT, dir = "long", idvar = 1:2, varying = list(3:7),
> v.names = "Int.Prev.Est", timevar = "cat")
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
More information about the R-help
mailing list