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
This works:
REP <- rep(1:nrow(df), 3) df2 <- data.frame(df[REP, ], Time = rep(1:3, each = 9)) rownames(df2) <- NULL df2