Advertisement
Guest User

updatedFix

a guest
Mar 20th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.88 KB | None | 0 0
  1. require(zoo)
  2. require(chron)
  3. setwd("/home/knavero/Desktop/")
  4.  
  5. fmt = "%m/%d/%Y %H:%M"
  6. tail1 = function(x) tail(x, 1)
  7. rawData = read.zoo("weatherData.txt", header = T, FUN = as.chron,
  8.    format = fmt, sep = "\t", aggregate = tail1)
  9.  
  10. temp = as.numeric(as.vector(rawData))
  11. rawData = suppressWarnings(zoo(cbind(temp = temp),
  12.    time(rawData)))
  13.  
  14. oneMin = seq(start(rawData), end(rawData), by = times("00:01:00"))
  15. intData = (na.approx(rawData, xout = oneMin))
  16.  
  17. #par(mfrow = c(3, 1), oma = c(0, 0, 2, 0), mar = c(1, 4, 1, 1))
  18.  
  19. #suppressWarnings(plot(rawData, type = "p", ylim = c(0, 100)))
  20. #grid(col = "darkgrey")
  21.  
  22. #plot(intData, type = "p", ylim = c(0, 100))
  23. #grid(col = "darkgrey")
  24.  
  25. min = times("00:15:00")
  26. offset = min*1/2
  27. avgData = suppressWarnings(aggregate(intData, trunc(time(intData) + offset, min), mean))
  28.  
  29. #plot(avgData, type = "p", ylim = c(0, 100))
  30. #grid(col = "darkgrey")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement