Add missing values/timestamps
Thanks a lot!
The way with zoo worked perfect.
Here is the code I've used finally:
data.input01 <-read.csv("./1_15min.txt", header = TRUE, sep = ";",
quote="\"", dec=",", fill = TRUE, comment.char="")
data.input02 <-read.csv("./2_15min.txt", header = TRUE, sep = ";",
quote="\"", dec=",", fill = TRUE, comment.char="")
data.input03 <-read.csv("./3_15min.txt", header = TRUE, sep = ";",
quote="\"", dec=",", fill = TRUE, comment.char="")
data.troughput01 <- rbind(data.input01,data.input02,data.input03)
data.test <- seq(as.POSIXct("2006-01-01 00:00:00"),as.POSIXct("2006-12-31
23:45:00"),900)
data.troughput02 <- as.zoo(data.troughput01$V2)
index(data.troughput02) <- as.POSIXct(data.troughput01$V1)
data.output01 <- merge(data.troughput04,zoo(,data.test))
data.output02 <- na.approx(data.output01,na.rm = FALSE)
Gabor Grothendieck wrote:
Try this where we read in a zoo series and then merge it with a zero width regularly spaced series to create the result. Lines <- "V1,V2 2008-10-14 08:45:00,94411.08 2008-10-14 08:50:00,90745.45 2008-10-14 08:55:00,82963.35 2008-10-14 09:00:00,75684.38 2008-10-14 09:05:00,78931.82 2008-10-14 09:20:00,74580.11 2008-10-14 09:25:00,69666.48 2008-10-14 09:30:00,77794.89" library(zoo) z <- read.zoo(textConnection(Lines), header = TRUE, sep = ",", tz = "") tt <- seq(time(z)[1], time(z)[length(z)], 5*60) merge(z, zoo(, tt)) The last statement's output will be:
merge(z, zoo(, tt))
2008-10-14 08:45:00 2008-10-14 08:50:00 2008-10-14 08:55:00 2008-10-14
09:00:00
94411.08 90745.45 82963.35
75684.38
2008-10-14 09:05:00 2008-10-14 09:10:00 2008-10-14 09:15:00 2008-10-14
09:20:00
78931.82 NA NA
74580.11
2008-10-14 09:25:00 2008-10-14 09:30:00
69666.48 77794.89
See the 3 zoo vignettes for use of zoo series and R News 4/1 (for
date/time info).
On Mon, Mar 30, 2009 at 10:38 AM, j.k <kathan at gmx.at> wrote:
Hello alltogheter, I have the following problem and maybe someone can help me with it. I have a list of values with times. They look like that: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? V1 ? ? ? ? ? V2 1 2008-10-14 08:45:00 94411.08 2 2008-10-14 08:50:00 90745.45 3 2008-10-14 08:55:00 82963.35 4 2008-10-14 09:00:00 75684.38 5 2008-10-14 09:05:00 78931.82 6 2008-10-14 09:20:00 74580.11 7 2008-10-14 09:25:00 69666.48 8 2008-10-14 09:30:00 77794.89 I have these data combined from different series of measurements. As you can see the problem is that between these series are gaps which I want to fill. The format of the time is POSIXct Are there any suggestions how I can fill these missing times and afterwards interpolate/predict their values? Thanks in advance Johannes -- View this message in context: http://www.nabble.com/Add-missing-values-timestamps-tp22784737p22784737.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
View this message in context: http://www.nabble.com/Add-missing-values-timestamps-tp22784737p22863325.html Sent from the R help mailing list archive at Nabble.com.