Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Gabor Grothendieck
On Fri, Aug 20, 2010 at 9:59 AM, Cecilia Carmo wrote: > The last one worked! The other one, not. > Thank you very much! > > Another question about merge(): sometimes I'm merging two dataframes and the > merged dataframe has much more rows than the two merged? I think this should > not happen,does

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Cecilia Carmo
The last one worked! The other one, not. Thank you very much! Another question about merge(): sometimes I'm merging two dataframes and the merged dataframe has much more rows than the two merged? I think this should not happen,does it? Cecília Em Fri, 20 Aug 2010 09:37:26 -0400 Gabor Grot

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Gabor Grothendieck
On Fri, Aug 20, 2010 at 9:33 AM, Gabor Grothendieck wrote: > On Fri, Aug 20, 2010 at 9:27 AM, Cecilia Carmo wrote: >> It wasn't the merge command. It doesn't create the variable x3. >> >> Cecília >> >> > > How about: > > x$k3 <- with(x, unlist(tapply(k1, k1, seq_along))) > y$k3 <- with(y, unlist(

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Gabor Grothendieck
On Fri, Aug 20, 2010 at 9:27 AM, Cecilia Carmo wrote: > It wasn't the merge command. It doesn't create the variable x3. > > Cecília > > How about: x$k3 <- with(x, unlist(tapply(k1, k1, seq_along))) y$k3 <- with(y, unlist(tapply(k1, k1, seq_along))) __

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Cecilia Carmo
It wasn't the merge command. It doesn't create the variable x3. Cecília Em Fri, 20 Aug 2010 09:22:29 -0400 Gabor Grothendieck escreveu: On Fri, Aug 20, 2010 at 9:07 AM, Cecilia Carmo wrote: This is what I need, but my dataframe has many rows and it returns to me the following message: E

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Gabor Grothendieck
On Fri, Aug 20, 2010 at 9:07 AM, Cecilia Carmo wrote: > This is what I need, but my dataframe has many rows and it returns to me the > following message: > > Error: cannot allocate vector of size 120 Kb > In addition: There were 18 warnings (use warnings() to see them) > Assuming that its the mer

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Cecilia Carmo
The rule is not important to me. I'm selecting a sample that must have one important feature: the same number of obs from x and from y with the same k1. Thanks Cecília Em Fri, 20 Aug 2010 08:28:24 -0400 David Winsemius escreveu: On Aug 20, 2010, at 6:44 AM, Cecilia Carmo wrote: Hi everyo

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Cecilia Carmo
This is what I need, but my dataframe has many rows and it returns to me the following message: Error: cannot allocate vector of size 120 Kb In addition: There were 18 warnings (use warnings() to see them) Could you help me, Thanks Cecília Em Fri, 20 Aug 2010 08:30:16 -0400 Gabor Grothendi

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Kay Cichini
..gabor gave the solution during i was typing - so please disregard this. yours, kay - Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck -- View this message in context: http://r.789695.n4.nabble.com/paired-samples-m

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Kay Cichini
hello cecilia, i tried: yn<-y[y$k1%in%x$k1,] xn<-x[x$k1%in%y$k1,] x1st<-unique(match(yn$k1,xn$k1)) y1st<-unique(match(xn$k1,yn$k1)) new<-cbind(k1=intersect(y$k1,x$k1),k2.x=xn[x1st,2],k2.y=yn[y1st,2]) giving: k1 k2.x k2.y [1,] 1 20 10 [2,] 2 22 12 [3,] 3 23 14 [4,] 5 25

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Gabor Grothendieck
On Fri, Aug 20, 2010 at 6:44 AM, Cecilia Carmo wrote: > Hi everyone! > > I'm matching two samples to create one sample that have > pairs of observations equal for the k1 variable. Merge() doesn't work > because I dont't want to recycle the values. > > x <- data.frame(k1=c(1,1,2,3,3,5), k2=c(20,21,

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread David Winsemius
On Aug 20, 2010, at 6:44 AM, Cecilia Carmo wrote: Hi everyone! I'm matching two samples to create one sample that have pairs of observations equal for the k1 variable. Merge() doesn't work because I dont't want to recycle the values. When there is more than one possible match in either y o

Re: [R] paired samples, matching rows, merge()

2010-08-20 Thread Wu Gong
Hi Cecília, Assuming that you want to pair two samples as more as possible, let's relabel the k1 indices. The x$k1 c(1,1,2,3,3,5) could be relabeled as c(1.01,1.02,2.01,3.01,3.02,5.01), so as y$k1. x$k1 <- x$k1+sequence(rle(x$k1)$lengths)/100 y$k1 <- y$k1+sequence(rle(y$k1)$lengths)/100 merge(x

[R] paired samples, matching rows, merge()

2010-08-20 Thread Cecilia Carmo
Hi everyone! I'm matching two samples to create one sample that have pairs of observations equal for the k1 variable. Merge() doesn't work because I dont't want to recycle the values. x <- data.frame(k1=c(1,1,2,3,3,5), k2=c(20,21,22,23,24,25)) x y <- data.frame(k1=c(1,1,2,2,3,4,5,5), k2=c(1