I have two columns in my data as shown below. I want to insert rows based on the value in Total column. Eg. For record1, the total value is 9. So, there should be 9 records for
library(data.table) setDT(df)[,.(Total=1:Total), code]
Or base R:
R
with(df, data.frame(code=rep(code, Total), Total=sequence(Total)))