[R] Using "rep", but don't know what to put after each =

joe1985 johannes at dsr.life.ku.dk
Fri Feb 20 12:49:58 CET 2009


Hello

I have one DF (detheleny1periode), with some variables that mathes, in some
way, variables in another DF (y2).

The DF named detheleny1periode look like this (i have not included alle
variables):

CHR_NR      diffdatoperiode
11377                29
11377                59  
11377                78 

with many different CHR_NR's.

And the other DF named y2 look like this (i have not included alle
variables):

CHR_NR  variab
11377       1
11377       0
11377       1
11377       0
11377       0
11377       0
11377       1
11377       0
11377       0
11377       0
11377       0
11377       0
11377       0

again with many different CHR_NR's.

So what want is to make it look like this:

CHR_NR  variab             x
11377       1               29
11377       0               29
11377       1               59
11377       0               59
11377       0               59
11377       0               59
11377       1               78 
11377       0               78  
11377       0               78
11377       0               78
11377       0               78
11377       0               78
11377       0               78

So i thougth i could use y2$x <- rep(c(detheleny1periode$diffdatoperiode,
each= ), but my problem is that i don't what to put after  "each=" because
the number of rows differs a lot between each "CHR_NR", but what i do know
is that want the detheleny1periode$diffdatoperiode repeated the times theres
is between each "1" in "variab", as I illustrated above. 

Hope you can help me

 
-- 
View this message in context: http://www.nabble.com/Using-%22rep%22%2C-but-don%27t-know-what-to-put-after-each-%3D-tp22119236p22119236.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list