Guest User

Untitled

a guest
Jan 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. start <- as.POSIXlt(c('2017-1-1 1:00','2017-1-1 2:00','2017-1-2 1:00','2017-1-2 2:00'))
  2. values <- as.numeric(c(2,5,4,3))
  3. df <- data.frame(start,values)
  4. df
  5.  
  6. start values
  7. 1 2017-01-01 01:00:00 2
  8. 2 2017-01-01 02:00:00 5
  9. 3 2017-01-02 01:00:00 4
  10. 4 2017-01-02 02:00:00 3
  11.  
  12. MaxValueDay <- as.numeric(c(5,5,4,4))
  13. MaxValueYesterday <- as.numeric(c(NA,NA,5,5))
  14. PreviousHourValue <- as.numeric(c(NA,2,NA,4))
  15. df2 <- data.frame(start,values,MaxValueDay,MaxValueYesterday,PreviousHourValue)
  16. df2
  17.  
  18. start values MaxValueDay MaxValueYesterday PreviousHourValue
  19. 1 2017-01-01 01:00:00 2 5 NA NA
  20. 2 2017-01-01 02:00:00 5 5 NA 2
  21. 3 2017-01-02 01:00:00 4 4 5 NA
  22. 4 2017-01-02 02:00:00 3 4 5 4
Add Comment
Please, Sign In to add comment