I have a data.frame df and I want that every row in this df is duplicated lengthTime times and that a new column is added that counts
df
lengthTime
Why not just something like df[rep(1:nrow(df),times = 3),] to extend the data frame, and then add the extra column just as you have above, with df$Time <- rep(1:lengthTime, each=nrRow)?
df[rep(1:nrow(df),times = 3),]
df$Time <- rep(1:lengthTime, each=nrRow)