Skip to content
Prev 325118 / 398503 Next

Speed up or alternative to 'For' loop

Well, speaking of hasty...

This will also do it, provided that each tree's initial height is less
than the previous tree's final height. In principle, not a safe
assumption, but might be ok depending on where the data came from.

df$delta <- c(NA,diff(df$Height))
df$delta[df$delta < 0] <- NA

-Don