You can avoid the loop if you want (and more R'ish)
d <- data.frame(Site=c("LM1","LM2"),speciescode=c("MkI","KiU"),abundance=c(3,4),time=c(3, 4))
dnew <- d[rep(1:nrow(d), d$time), ]
dnew[ ,1:3]
#
#
#
#
#
#
#
#
You can also change the abundance value using the @BlueMagister method.
source
share