Skip to content
Prev 176132 / 398503 Next

Filling in Gapped Interval of a Data Frame As Series

one way is the following:

dat. <- data.frame(V1 = min(dat$V1):max(dat$V1), V2 = 0)
newdat <- merge(dat, dat., by = "V1", all.y = TRUE, suffixes = c("", "."))
newdat$V2[na.ind] <- newdat$V2.[na.ind <- is.na(newdat$V2)]
newdat[-3]


I hope it helps.

Best,
Dimitris
Gundala Viswanath wrote: