Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require(zoo)
- require(chron)
- fmt = "%m/%d/%Y %H:%M"
- tail1 = function(x) tail(x, 1)
- old = read.zoo("old.txt", header = F,
- FUN = as.chron, format = fmt,
- colClasses = c(NA, "numeric", "NULL"),
- sep = "\t", aggregate = tail1)
- new = read.zoo("new.txt", header = T,
- FUN = as.chron, format = fmt,
- sep = ",",
- colClasses = c("NULL", NA, "numeric",
- "NULL", "NULL",
- "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL",
- "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"),
- aggregate = tail1)
- min = seq(start(new), end(new), by = times("00:01:00"))
- intData = na.approx(new, xout = min)
- min = times("00:15:00")
- offset = min*1/2
- avgData = suppressWarnings(aggregate(intData,
- trunc(time(intData) + offset, min), mean))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement