[R] Merging
Annette Heisswolf
annette.heisswolf at utu.fi
Tue Mar 17 14:23:44 CET 2009
Tammy,
You won't get more help if you post this again every half an hour... I don't quite understand what you exactly want to do, but it seemed at
least to me that Keith's suggestion (see again below) pretty much does what you want. If not, could you please specify *EXACTLY* what you
want to do. Thanks!
Annette
> From: Keith Jewell <k.jewell_at_campden.co.uk>
> Date: Tue, 17 Mar 2009 12:23:34 +0000
>
> Is this what you want it to do? (aDF is the original data frame)
>
>> aDF
>
> V1 V2 V3 V4
> 1 2006-02-22 16:28:18 useractivity_act 8 0
> 2 2006-02-22 16:28:26 4 2 0
> 3 2006-02-22 16:28:28 3 3 0
> 4 2006-02-22 16:28:31 4 4 1
> 5 2006-02-22 16:28:35 3 159 0
> 6 2006-02-22 16:31:14 useractivity_idle 0 0
> 7 2006-02-22 16:28:18 useractivity_act 8 0
> 8 2006-02-22 16:28:26 4 2 0
> 9 2006-02-22 16:28:28 3 3 0
> 10 2006-02-22 16:28:31 4 4 0
> 11 2006-02-22 16:28:35 3 159 25
>
> 12 2006-02-22 16:31:14 useractivity_idle 0 0
>> with(aDF, aggregate(V4, by=list(V1, V2, V3), sum))
>
> Group.1 Group.2 Group.3 x
> 1 2006-02-22 16:31:14 useractivity_idle 0 0
> 2 2006-02-22 16:28:26 4 2 0
> 3 2006-02-22 16:28:28 3 3 0
> 4 2006-02-22 16:28:31 4 4 1
> 5 2006-02-22 16:28:18 useractivity_act 8 0
> 6 2006-02-22 16:28:35 3 159 25
>
>
> hth
>
> Keith J
Tammy Ma schrieb:
> I still couldn't solve it........any help would be preciated!
>
>
>
> Tammy
>
>
>
>
>
>> From: metal_licaling at live.com
>> To: r-help at r-project.org
>> Date: Tue, 17 Mar 2009 11:49:10 +0200
>> Subject: [R] Merging
>>
>>
>> Hi, All.
>>
>>
>> I have a data frame with the part as :
>>
>> .....
>> 142 2006-02-22 16:28:18 useractivity_act 8 0
>> 143 2006-02-22 16:28:26 4 2 0
>> 144 2006-02-22 16:28:28 3 3 0
>> 145 2006-02-22 16:28:31 4 4 1
>> 146 2006-02-22 16:28:35 3 159 0
>> 147 2006-02-22 16:31:14 useractivity_idle 0 0
>> 1421 2006-02-22 16:28:18 useractivity_act 8 0
>> 1431 2006-02-22 16:28:26 4 2 0
>> 1441 2006-02-22 16:28:28 3 3 0
>> 1451 2006-02-22 16:28:31 4 4 0
>> 1461 2006-02-22 16:28:35 3 159 25
>> 1471 2006-02-22 16:31:14 useractivity_idle 0 0
>> ....
>>
>> I want to merge the above as
>> 142 2006-02-22 16:28:18 useractivity_act 8 0
>>
>> 143 2006-02-22 16:28:26 4 2 0
>>
>> 144 2006-02-22 16:28:28 3 3 0
>>
>> 145 2006-02-22 16:28:31 4 4 1
>>
>> 146 2006-02-22 16:28:35 3 159 25
>>
>> 147 2006-02-22 16:31:14 useractivity_idle 0 0
>>
>> How should I do`??
>> Thanks.
>>
>> Tammy
--
Annette Heisswolf
Section of Ecology
Department of Biology
University of Turku
20014 Turku, Finland
More information about the R-help
mailing list