Re: [R] generating new data with for loop

2009-06-09 Thread Ben Bolker
Bugzilla from gordon.holtslan...@usask.ca wrote: > > I'm new at R ... > I've not done for loops in R - so this is very new to me. > > One of our students has a data frame that contains two columns data > > 1. unixtime time of an event (in unix time - #of seconds) > 2. duration of event in sec

Re: [R] generating new data with for loop

2009-06-09 Thread Henrique Dallazuanna
Try this: x <- data.frame(u=c(1:5), seconds=sample(5)) transform(x[rep(1:nrow(x),x$seconds),], seconds = unlist(lapply(split(x$seconds, x$u), seq))) On Tue, Jun 9, 2009 at 6:11 PM, Gordon J Holtslander < gordon.holtslan...@usask.ca> wrote: > I'm new at R ... > I've not done for loops in R - so

[R] generating new data with for loop

2009-06-09 Thread Gordon J Holtslander
I'm new at R ... I've not done for loops in R - so this is very new to me. One of our students has a data frame that contains two columns data 1. unixtime time of an event (in unix time - #of seconds) 2. duration of event in seconds. We need to create new data - the unixtime (seconds) that these