Skip to content

Merging

15 messages · Tammy Ma, Simon Pickett, Pankaj Chopra +2 more

#
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.
#
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:
#
Is this what you want it to do? (aDF is the original data frame)
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
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...
#
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
Tammy Ma schrieb:

  
    
#
Looks as if you copied my code without modifying to suit your data frame. 
My data frame (aDF) had column names V1, V2, V3, V4
'data.frame':   12 obs. of  4 variables:
 $ V1: chr  "2006-02-22 16:28:18" "2006-02-22 16:28:26" "2006-02-22 
16:28:28" "2006-02-22 16:28:31" ...
 $ V2: Factor w/ 4 levels "3","4","useractivity_act",..: 3 2 1 2 1 4 3 2 1 2 
...
 $ V3: num  8 2 3 4 159 0 8 2 3 4 ...
 $ V4: num  0 0 0 1 0 0 0 0 0 0 ...

..so I referred to V1, V2, V3, V4 in the aggregate. We don't know the column 
names in your data frame, which I guess is called act_data12. (By the way, 
you told us almost nothing about your data frame. Consider reading and 
following the posting guide.) What does
produce?

hth

Keith J
==========================
"Tammy Ma" <metal_licaling at live.com> wrote in message 
news:BAY0-DP1-6D9323FB68F77E4CFA77186980 at phx.gbl...

Thanks.

Actually, I have been trying many time using method from KJ, There is always 
the following information coming up or Rgui exit without reason.. I have no 
idea about this?

gh<-with(act_data12, aggregate(V4, by=list(V1,V2,V3), sum))
Error in unlist(y, recursive = FALSE) :
  promise already under evaluation: recursive default argument reference or 
earlier problems?

Tammy
_________________________________________________________________
Drag n' drop-Get easy photo sharing with Windows LiveT Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx




--------------------------------------------------------------------------------
#
In case it helps, this refers to the columns by position rather than name...
It sums the fourth column (I'm guessing this is what Tammy meant by "merge") 
for unique combinations of all columns except the fourth.

It doesn't need the column names inside the aggregate, but does need the 
dataframe name. Because the dataframe name is specified inside the 
aggregate, we don't need the with().

HTH

Keith J

"Keith Jewell" <k.jewell at campden.co.uk> wrote in message 
news:gpoc8f$jl0$1 at ger.gmane.org...
#
OK, I can't see anything wrong with that.

a) post the results of ...
... 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
HTH

Keith J
"Tammy Ma" <metal_licaling at live.com> wrote in message 
news:BAY0-DP4-773C6BFDDC43849F5DC6786980 at phx.gbl...