You could use lapply
to create a data.frame
for each segement then rbind
all the results together at the end, like this...
res <- lapply( 1:nrow(df) , function(x){ data.frame(
datetime = strptime( df[ x , 1 ] , format = "%d/%m/%Y %H:%M:%S" ) + ( seq_len( df[ x , 2 ] ) - 1 ) ,
duration = rep( 1 , df[ x , 2 ] ) ,
mean = rep( df[ x , 3 ] , df[ x , 2 ] ) ) } )
do.call( rbind , res )
# datetime duration mean
#1 2013-04-14 17:42:29 1 1.17
#2 2013-04-14 17:43:49 1 2.36
#3 2013-04-14 17:43:50 1 2.36
#4 2013-04-14 17:43:51 1 2.36
#5 2013-04-14 17:43:52 1 2.36
#6 2013-04-14 17:43:53 1 2.36
#7 2013-04-14 17:43:58 1 1.05
#8 2013-04-14 17:43:59 1 1.05
#9 2013-04-14 17:44:03 1 1.43
#10 2013-04-14 17:44:04 1 1.43
#11 2013-04-14 17:44:05 1 1.43
#12 2013-04-14 17:44:11 1 1.47
#13 2013-04-14 17:44:12 1 1.47