posixct

How to get last data for each id/date?

五迷三道 提交于 2019-12-29 01:32:29
问题 I have a data frame that contains id, POSIXct(Date & Time) > myData Tpt_ID Tpt_DateTime Value 1 1 2013-01-01 15:17:21 CST 10 2 2 2013-01-01 15:18:32 CST 5 3 3 2013-01-01 16:00:02 CST 1 4 1 2013-01-02 15:10:11 CST 15 5 2 2013-02-02 11:18:32 CST 6 6 3 2013-02-03 12:00:02 CST 2 7 1 2013-01-01 19:17:21 CST 21 8 2 2013-02-02 20:18:32 CST 8 9 3 2013-02-03 22:00:02 CST 3 I'd like to get last Value for each Date and ID For example, Tpt_ID Tpt_DateTime Value 2 2013-01-01 15:18:32 CST 5 3 2013-01-01 16

Does fasttime cache values outside of it's environment? If so, why?

只谈情不闲聊 提交于 2019-12-25 02:56:12
问题 DISCLAIMER: I assume 'cache' and 'environment' are the right words here, though I am new to programming, so I may have misunderstood the terminology. I have recently been trying to get to grips with the package fasttime for R, and I realise know there it has a behavior that I've not seem in documentation and also has been the root of my problems getting it to function. TL;DR - If I use fast time to convert to POSIXct from a parent object into child one, then use it in a different way to

discontinuity in evaluation of midnight POSIXct objects

╄→尐↘猪︶ㄣ 提交于 2019-12-24 08:24:54
问题 I have a vector of POSIXct objects with date and time, one of which is midnight. v <- as.POSIXct(c("2019-01-01 23:59:00","2019-01-02 00:00:00"), tz="UTC") When I evaluate v , it is shown correctly, > v [1] "2019-01-01 23:59:00 UTC" "2019-01-02 00:00:00 UTC" but when I evaluate its elements separately, > v[1] [1] "2019-01-01 23:59:00 UTC" > v[2] [1] "2019-01-02 UTC" the midnight element is shortened to exclude the time, which causes trouble in my data.table join. I therefore wonder whether it

How to get time differences with output having multiple units

泪湿孤枕 提交于 2019-12-24 05:20:09
问题 Good day, I have two date columns in as.POSIXct in the format YYYY-MM-DD HH:MM:SS. I would like to get the difference between the two, displayed in the format Days Hours:Seconds. Here is some dummy data: a<-c("2018-03-20 11:52:25 AST", "2018-03-20 12:51:25 AST", "2018-03-20 14:19:04 AST", "2018-03-21 14:12:12 AST", "2018-03-21 12:09:22 AST", "2018-03-21 15:28:01 AST") b<-c("2018-04-09 18:39:38 AST", "2018-06-23 19:13:14 AST", "2018-03-20 23:23:03 AST", "2018-05-10 21:29:28 AST", "2018-03-22

Adding timezone to POSIXct object in data.table

笑着哭i 提交于 2019-12-24 03:46:11
问题 I have a data.table object with the columns date and time stored as IDate/ITime objects. I also have a time zone column where the time zone is given as character. Now I want to create a column DateTime that is using the POSIXct format. However I can't figure out how to add the correct time zone to the object. #Create the data.table object dtData <- data.table( Index = seq(1,5), Time= as.ITime(c('16:00', '16:00', '12:30', '16:00', '15:00')), Date = as.IDate(rep('2015-05-28', 5)), TimeZone=c(

ggplot2: shade alternate days with POSIXct timestamp data

天大地大妈咪最大 提交于 2019-12-23 19:07:51
问题 I can plot a line of a variable vs timestamp (plot p1 below). However, I'd like to shade the plot for alternate days. The data has an entry once an hour for two days. dat <-structure(list(TIMESTAMP = structure(c(2L, 3L, 14L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 15L, 16L, 17L, 18L, 26L, 27L, 38L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 39L, 40L, 41L, 42L), .Label = c("", "8/4/2013 0:50", "8/4/2013 1:50", "8

R- date time variable loses format after ifelse

倾然丶 夕夏残阳落幕 提交于 2019-12-23 15:13:09
问题 I have a variable in the proper POSIXct format, converted with ymd_hms(DateTime) {lubridate}. However, after a transformation the variable loses its POSIXct format: daily$DateTime<- ifelse(daily$ID %in% "r1_1"|daily$ID %in% "r1_2", NA,daily$DateTime) I try to convert the variable again to POSIXct with lubridate, but it seems it does´t like the NAs, and, in addition, now the variable DateTime has a num format that lubridate does´t recognise as a date and time format (e.g. 1377419400). Please,

difftime between 2 columns and next.row within a variable

此生再无相见时 提交于 2019-12-23 05:04:51
问题 Trying to caulculate the difference in time between two two columns, however time 2 in 'difftime' is in the next.row sample data: structure(list(code = c(10888, 10888, 10888, 10888, 10888, 10888, 10889, 10889, 10889, 10889, 10889, 10889, 10890, 10890, 10890 ), station = c("F1", "F3", "F4", "F5", "L5", "L7", "F1", "F3", "F4", "L5", "L6", "L7", "F1", "F3", "F5"), a = structure(c(1365895151, 1365969188, 1366105495, 1367433149, 1368005216, 1368011698, 1366244224, 1366414926, 1367513240,

difftime between 2 columns and next.row within a variable

我的未来我决定 提交于 2019-12-23 05:03:29
问题 Trying to caulculate the difference in time between two two columns, however time 2 in 'difftime' is in the next.row sample data: structure(list(code = c(10888, 10888, 10888, 10888, 10888, 10888, 10889, 10889, 10889, 10889, 10889, 10889, 10890, 10890, 10890 ), station = c("F1", "F3", "F4", "F5", "L5", "L7", "F1", "F3", "F4", "L5", "L6", "L7", "F1", "F3", "F5"), a = structure(c(1365895151, 1365969188, 1366105495, 1367433149, 1368005216, 1368011698, 1366244224, 1366414926, 1367513240,

scale_datetime shifts x axis [duplicate]

天涯浪子 提交于 2019-12-22 18:33:00
问题 This question already has answers here : Time series plot gets offset by 2 hours if scale_x_datetime is used (2 answers) Closed 3 years ago . I am trying to plot a time series that has an x axis of class "POSIXct" using ggplot2, which is working up to a point. When I try to manipulate the x axis breaks and labels using scale_x_datetime it generates a one month shift in the x axis. Can anyone explain this, and provide a solution? Example simplified code: start <- as.POSIXct("2014/07/01 00:00