posixct

Parse ISO 8601 combined date and time YYYY-MM-DDTHH-MM-SSZ

China☆狼群 提交于 2020-07-03 13:01:08
问题 I have a large dataframe with time stamps that look like this: "2019-05-15T01:42:15.072Z" It resembles a ISO 8601 combined date and time representation. How can I parse this string into a real date-time format? The characters ( T and Z ) inside the data seems to make it difficult. 回答1: You can simply parse the timestamp by specifying the format in as.POSIXct (or strptime ) as.POSIXct("2019-05-15T01:42:15.072Z", format = "%Y-%m-%dT%H:%M:%OSZ") #[1] "2019-05-15 01:42:15 AEST" Explanation: %Y ,

Error time_trans works with objects of class posixct only in R

青春壹個敷衍的年華 提交于 2020-05-31 10:12:20
问题 I got the Error: Invalid input: time_trans works with objects of class POSIXct only when I run the program in shiny. And this is my code in shiny : library(ggplot2) library(Cairo) # For nicer ggplot2 output when deployed on Linux library(shiny) ui <- fluidPage( fluidRow( column(width = 4, class = "well", h4("Brush and double-click to zoom"), plotOutput("plot1", height = 300, dblclick = "plot1_dblclick", brush = brushOpts( id = "plot1_brush", resetOnNew = TRUE ))), column(width = 6, plotOutput

How can I rearrange the date from d-m-y to m-d-y in R?

情到浓时终转凉″ 提交于 2020-03-03 09:21:31
问题 I am having issues with the following R code. I am trying to rearrange csv date values in a column from day-month-year to month-day-year. To issues arise: the format is changed to year-month-day instead, and this error message appears when I attempt to plot the results: Error: Column New_Date is a date/time and must be stored as POSIXct, not POSIXlt. I am new to R and unsure on how to fix this error. I have gone through a lot of similar topics, however because of lack of knowledge in R, I am

How to format fractional seconds in POSIXct in r

亡梦爱人 提交于 2020-02-24 11:30:07
问题 I have read other questions regarding this topic but they do not seem to work on my dataset: Timestamp Bid.price Ask.price Bid.volume Ask.volume 20070313 07:01:04:762 11.14122 11.14478 4.539397 1.891416 20070313 07:01:07:608 11.13930 11.14670 1.277812 3.066750 20070313 07:01:08:701 11.14095 11.14505 0.050396 0.050396 20070313 07:01:11:275 11.14098 11.14502 0.226505 0.543613 20070313 07:01:13:884 11.13930 11.14670 0.322856 0.774855 20070313 07:01:16:588 11.13930 11.14670 0.405654 0.973569 I

Add one year to a posix time [duplicate]

守給你的承諾、 提交于 2020-01-30 04:33:35
问题 This question already has answers here : Add a month to a Date [duplicate] (8 answers) How to subtract years? (6 answers) Closed 2 years ago . I have a date like "2016-01-01" (YYYY-MM-DD) and I'm using as.numeric(as.POSIXct(...)) to use it as an Integer. My question is, is there a way to add to this date a year, a month or a day ? I mean, if I add one year to 2016 it wont be the same as adding a year to 2015 (bissextile stuff). Same as adding 32 days to January 01 wont be the same as adding

How can I assign the value from one of two POSIXct columns in a data.frame to a new POSIXct column?

倖福魔咒の 提交于 2020-01-25 19:50:30
问题 I have a data.frame with two columns of type POSIXct, though for every row, only one column will have a value, e.g., dd <- data.frame(date1 = c(now(), NA), date2 = c(as.POSIXct(NA), now())) > dd date1 date2 1 2016-05-06 11:30:04 <NA> 2 <NA> 2016-05-06 11:30:04 I would now like to create a third column that will contain the value of whichever column has a non-NA value, i.e., the result should look like > dd date1 date2 date3 1 2016-05-06 11:26:36 <NA> 2016-05-06 11:26:36 2 <NA> 2016-05-06 11

Improve performance of data.table date+time pasting?

删除回忆录丶 提交于 2020-01-22 19:31:19
问题 I am not sure that I can ask this question here, let me know if I should do it somewhere else. I have a data.table with 1e6 rows having this structure: V1 V2 V3 1: 03/09/2011 08:05:40 1145.0 2: 03/09/2011 08:06:01 1207.3 3: 03/09/2011 08:06:17 1198.8 4: 03/09/2011 08:06:20 1158.4 5: 03/09/2011 08:06:40 1112.2 6: 03/09/2011 08:06:59 1199.3 I am converting the V1 and V2 variables to a unique datetime variable, using this code: system.time(DT[,`:=`(index= as.POSIXct(paste(V1,V2), format='%d/%m/

Improve performance of data.table date+time pasting?

时光总嘲笑我的痴心妄想 提交于 2020-01-22 19:31:07
问题 I am not sure that I can ask this question here, let me know if I should do it somewhere else. I have a data.table with 1e6 rows having this structure: V1 V2 V3 1: 03/09/2011 08:05:40 1145.0 2: 03/09/2011 08:06:01 1207.3 3: 03/09/2011 08:06:17 1198.8 4: 03/09/2011 08:06:20 1158.4 5: 03/09/2011 08:06:40 1112.2 6: 03/09/2011 08:06:59 1199.3 I am converting the V1 and V2 variables to a unique datetime variable, using this code: system.time(DT[,`:=`(index= as.POSIXct(paste(V1,V2), format='%d/%m/

work around to specifying date range in ifelse statement in R

落爺英雄遲暮 提交于 2020-01-15 12:15:30
问题 I am trying to create a new column denoting quarter in my data.frame using an ifelse statement on a date column of class as.POSIXct . this is a short verion of the date a spot.id local.date q12014local.1 11824267 2013-12-30 q12014local.2 11825708 2013-12-30 q12014local.3 11823669 2013-12-30 q12014local.4 11825407 2013-12-30 q12014local.5 11824268 2013-12-30 q12014local.6 11825709 2013-12-30 q12014local.7 11823670 2013-12-30 q12014local.8 11825408 2013-12-30 q12014local.9 11824266 2013-12-31

Calculate time difference (difftime) between columns of different rows

╄→尐↘猪︶ㄣ 提交于 2020-01-13 19:07:35
问题 I have data on 'Start' and 'End' time for different jobs, grouped by 'owner': Data <- data.frame( job = c(1, 2, 3, 4, 5), owner = c("name1", "name2", "name1", "name1", "name2"), Start = as.POSIXct(c("2015-01-01 15:00:00", "2015-01-01 15:01:00", "2015-01-01 15:13:00", "2015-01-01 15:20:00", "2015-01-01 15:39:02"), format="%Y-%m-%d %H:%M:%S"), End = as.POSIXct(c("2015-01-01 15:11:11", "2015-01-01 15:17:21", "2015-01-01 15:17:00", "2015-01-01 15:31:21", "2015-01-01 15:40:11"), format="%Y-%m-%d