[R] Merging

Keith Jewell k.jewell at campden.co.uk
Tue Mar 17 17:32:33 CET 2009


OK, I can't see anything wrong with that.

a) post the results of ...
> sessionInfo()
... so we can check you're using a reasonably up to date system

b) send a copy of your data set to me at...
     k.jewell at campden.co.uk
... and I'll see if I can reproduce your error. I can take most common data 
formats, but you might want to use
> write.table(aDF, file.choose())

HTH

Keith J
"Tammy Ma" <metal_licaling at live.com> wrote in message 
news:BAY0-DP4-773C6BFDDC43849F5DC6786980 at phx.gbl...
>
> My data frame is:
>> str(act_data12)
> 'data.frame':   1687 obs. of  5 variables:
> $ Date        : chr  "2006-02-22" "2006-02-22" "2006-02-22" "2006-02-22" 
> ...
> $ Dtime       : chr  "14:36:10" "14:36:11" "14:36:12" "14:37:38" ...
> $ FocusApp_seq: chr  "useractivity_act" "4" "3" "0" ...
> $ App_duration: int  1 1 86 58 1 1 9 3 1 41 ...
> $ Frequency   : int  0 0 22 0 1 0 0 0 0 0 ...
>
> I used:
>
> gh<-with(act_data12, aggregate(Frequency, by=list(Date, Dtime, 
> FocusApp_seq, App_duration), sum))
>
> Error info:
>
> Error in unlist(y, recursive = FALSE) :
>
>  promise already under evaluation: recursive default argument reference or
>
> earlier problems?
>
>
> or R exited when running..
>
> Thanks for your concentration.
>
> Tammy
>
>
>
>> To: r-help at stat.math.ethz.ch
>> From: k.jewell at campden.co.uk
>> Date: Tue, 17 Mar 2009 12:23:34 +0000
>> Subject: Re: [R] Merging
>>
>> 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" <metal_licaling at live.com> wrote in message
>> news:BAY0-DP3-858363E64F6ED84F9F6F486980 at phx.gbl...
>> >
>> > My aim is not only relect unduplicated column, I also want merge the 
>> > last
>> > column beside selection
>> > Thanks.
>> >
>> > Tammy
>> >
>> >
>> >
>> >
>> >> Date: Tue, 17 Mar 2009 06:59:20 -0400
>> >> From: pchopra at ncsu.edu
>> >> To: metal_licaling at live.com
>> >> CC: r-help at r-project.org
>> >> Subject: Re: [R] Merging
>> >>
>> >> Is this what you want it to do ('n' is the original data frame)?
>> >>
>> >>  > n
>> >>   v V1 V2 V3 V4
>> >> 1 k  a  2  1  2
>> >> 2 l  b  1  2  1
>> >> 3 m  c  2  1  2
>> >> 4 n  d  1  2  1
>> >> 5 o  e  2  1  2
>> >>  > n1 <- n[,3:5]
>> >>  > n2 <- duplicated(n1)
>> >>  > n3 <- n[!n2,]
>> >>  > n3
>> >>   v V1 V2 V3 V4
>> >> 1 k  a  2  1  2
>> >> 2 l  b  1  2  1
>> >>
>> >>
>> >> Pankaj
>> >>
>> >>
>> >> Tammy Ma wrote:
>> >> > Thanks for your reply,
>> >> >
>> >> > I couldn't use the method what the example gives. Because Data frame 
>> >> > is
>> >> > quite big, and it has so many rows which are repeated. I am not 
>> >> > pretty
>> >> > sure about the range of 1000. It turns out I should merge those row
>> >> > which repeated.
>> >> > Tammy
>> >> >
>> >> >
>> >> >> From: simon.pickett at bto.org
>> >> >> To: metal_licaling at live.com; r-help at r-project.org
>> >> >> Subject: Re: [R] Merging
>> >> >> Date: Tue, 17 Mar 2009 10:02:51 +0000
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> I'm pretty sure you dont mean "merge" since merge() creates a new 
>> >> >> big
>> >> >> data
>> >> >> frame from two small ones. It appears that you want to omit some 
>> >> >> rows.
>> >> >>
>> >> >> As I said before, get used to selecting rows like this
>> >> >>
>> >> >> data.frame<-data.frame[data.frame$conditional.rows>1000,]
>> >> >>
>> >> >> (for example)
>> >> >>
>> >> >> Although I dont have a clue what criteria you are using to select 
>> >> >> the
>> >> >> rows
>> >> >> you want...
>> >> >>
>> >> >> Simon.
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>> 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
>> >> >>> _________________________________________________________________
>> >> >>> Invite your mail contacts to join your friends list with Windows 
>> >> >>> Live
>> >> >>> Spaces. It's easy!
>> >> >>> http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
>> >> >>> [[alternative HTML version deleted]]
>> >> >>>
>> >> >>> ______________________________________________
>> >> >>> 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.
>> >> >>>
>> >> >>>
>> >> >
>> >> > _________________________________________________________________
>> >> > Invite your mail contacts to join your friends list with Windows 
>> >> > Live
>> >> > Spaces. It's easy!
>> >> > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
>> >> > [[alternative HTML version deleted]]
>> >> >
>> >> > ______________________________________________
>> >> > 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.
>> >> >
>> >
>> > _________________________________________________________________
>> > Invite your mail contacts to join your friends list with Windows Live
>> > Spaces. It's easy!
>> > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > 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.
>> >
>>
>> ______________________________________________
>> 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.
>
> _________________________________________________________________
> Invite your mail contacts to join your friends list with Windows Live 
> Spaces. It's easy!
> http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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