[R] Merging

Pankaj Chopra pchopra at ncsu.edu
Tue Mar 17 11:59:20 CET 2009


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.
>




More information about the R-help mailing list