[R] Faster way to zero-pad a data frame...?
    Rolf Turner 
    rolf at erdos.math.unb.ca
       
    Tue May 30 23:31:10 CEST 2006
    
    
  
Why not something simple like:
# Toy example:
data1 <- data.frame(time=c(0,1,5,10),events=c(1,30,14,4))
data2 <- rep(0,11) # Or more generally data2 <- rep(0,1+max(data1$time))
# You don't need a for loop! Use the indexing capabilities of R!
data2[data1$time+1] <- data1$events # The ``+1'' is to allow for 0-origin.
data2 <- ts(data2,start=0)
					???
			cheers,
				Rolf Turner
				rolf at math.unb.ca
    
    
More information about the R-help
mailing list