Try this:
> library(zoo)
> Lines <- "-8 100
+ -6 20.2
+ -1 1.5
+2 3.00
+3 78.8
+5 33.2
+6 44.5
+7 5.00"
> DF <- read.table(textConnection(Lines))
> z <- zoo(DF$V2, DF$V1)
> zz <- merge(z, zoo(, seq(min(time(z)), max(time(z, fill = 0
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:
Dear
Dear all,
I have a data frame that looks like this:
> dat
V1 V2
1 -8 100
2 -6 20.2
3 -1 1.5
4 2 3.00
5 3 78.8
6 5 33.2
7 6 44.5
8 7 5.00
Now I want to fill the V1 column in series (note that it is gapped),
with the corresponding value
3 matches
Mail list logo