posixct

Convert Factor to Date/Time in R

自闭症网瘾萝莉.ら 提交于 2019-11-27 22:13:50
This is the information contained within my dataframe: ## minuteofday: factor w/ 89501 levels "2013-06-01 08:07:00",... ## dDdt: num 7.8564 2.318 ... ## minutes: POSIXlt, format: NA NA NA I need to convert the minute of day column to a date/time format: minuteave$minutes <- as.POSIXlt(as.character(minuteave$minuteofday), format="%m/%d/%Y %H:%M:%S") I've tried as.POSIXlt , as.POSIXct and as.Date . None of which worked. Does anyone have ANY thoughts. The goal is to plot minutes vs. dDdt, but it won't let me plot in the specified time period that I want to as a factor. I have no idea what to try

Round a POSIX date (POSIXct) with base R functionality

醉酒当歌 提交于 2019-11-27 21:51:46
I'm currently playing around a lot with dates and times for a package I'm building. Stumbling across this post reminded me again that it's generally not a bad idea to check out if something can be done with basic R features before turning to contrib packages. Thus, is it possible to round a date of class POSIXct with base R functionality? I checked methods(round) which "only" gave me [1] round.Date round.timeDate* Non-visible functions are asterisked This is what I'd like to do (Pseudo Code) x <- as.POSIXct(Sys.time()) [1] "2012-07-04 10:33:55 CEST" round(x, atom="minute") [1] "2012-07-04 10

Milliseconds in POSIXct Class

穿精又带淫゛_ 提交于 2019-11-27 21:42:55
问题 How can I parse milliseconds correctly? as.POSIXct function works as following in my environment. > as.POSIXct("2014-02-24 11:30:00.001") [1] "2014-02-24 11:30:00.000 JST" > as.POSIXct("2014-02-24 11:30:00.0011") [1] "2014-02-24 11:30:00.001 JST" My R version is x86 v3.0.2 for Windows. 回答1: Specify the input format, using %OS to represent the seconds with their fractional parts. x <- c("2014-02-24 11:30:00.123", "2014-02-24 11:30:00.456") y <- as.POSIXct(x, format = "%Y-%m-%d %H:%M:%OS") When

Character POSIXct Conversion in R causes wrong timezone values on daylight saving time transition (CEST/CET))

只谈情不闲聊 提交于 2019-11-27 20:37:40
I have a problem converting POSIXct to character and back in POSIXct in R. I run the following code: time_seq_01 <- seq(as.POSIXct("2012-10-28 02:00:00"), by = 900, length.out = 10) time_seq_02 <- as.character(time_seq_01) time_seq_03 <- as.POSIXct(time_seq_02) or equivalent: time_seq_01 <- seq(as.POSIXct("2012-10-28 02:00:00"), by = 900, length.out = 10) time_seq_02 <- format(time_seq_01,usetz = TRUE) time_seq_03 <- as.POSIXct(time_seq_02) This are the timestamps in 2012 when the daylight saving transition from Central European Summer Time (CEST) to Central European Time (CET) occurs (Last

Returning a vector of class POSIXct with vapply

巧了我就是萌 提交于 2019-11-27 18:37:20
问题 I have list of dates having POSIXct class as follows (just a minimum working example): L <- list(as.POSIXct("2012-12-12 12:12:12"), as.POSIXct("2012-12-12 12:12:12")) I need to retrieve a vector of class POSIXct from it. This rules out lapply, and leaves me with sapply and vapply. I apply them as follows: sapply(L, "[[", 1) and this returns: [1] 1355310732 1355310732 Converting this vector to POSIXct gives error as origin must be provided. I also tried vapply: vapply(L, "[[", as.POSIXct(Sys

Exclude specific time periods in R

拜拜、爱过 提交于 2019-11-27 18:33:16
问题 I'm a beginner with R and have tried searching for data extraction for certain time periods but can't seem to find anything. I have a time series of continuous data measured at 10 minute intervals for a period of five months. For simplicity's sake, the data is available in two columns as follows: Timestamp Temp.Diff 2/14/2011 19:00 -0.385 2/14/2011 19:10 -0.535 2/14/2011 19:20 -0.484 2/14/2011 19:30 -0.409 2/14/2011 19:40 -0.385 2/14/2011 19:50 -0.215 ... And it goes on for the next five

Is there a fast parser for date

你。 提交于 2019-11-27 18:30:40
问题 For datetimes fasttime provides very fast parsing to POSIXct library('fasttime') library('lubridate') library('microbenchmark') # parse character to POSIXct Sys.setenv(TZ='UTC') test <- rep('2011-04-02 11:01:00',1e4) microbenchmark( test1 <- fastPOSIXct(test), test2 <- fast_strptime(test,format='%Y-%m-%d %H:%M:%S'), test3 <- as.POSIXct(test, format='%Y-%m-%d %H:%M:%S'), test4 <- ymd_hms(test), times=100) Unit: microseconds expr min lq mean median uq max test1 <- fastPOSIXct(test) 663.123 692

Remove seconds from time in R

五迷三道 提交于 2019-11-27 15:42:24
I am trying to remove the seconds from a column of hours in POSIXct format: #"2016-04-02 10:33:45 COT" "2016-04-02 22:19:24 COT" #"2016-04-09 17:47:13 COT" "2016-04-13 16:56:23 COT" x <- structure(c(1459589625, 1459631964, 1460220433, 1460562983), class = c("POSIXct", "POSIXt"), tzone = "") I am trying this but I am not seeing results: y <- as.POSIXct(x, format = "%d/%m/%Y %H:%M") statquant No you are giving as.POSIXct a wrong format... What about using format datetimes = as.POSIXct(c("2016-04-02 10:33:45 COT", "2016-04-02 22:19:24 COT" ,"2016-04-09 17:47:13 COT", "2016-04-13 16:56:23 COT")

understanding dates/times (POSIXc and POSIXct) in R

好久不见. 提交于 2019-11-27 15:15:06
问题 I'm reading a table and it contains strings that describe timestamps. I just want to convert from string to a built-in datetime type... R> Q <- read.table(textConnection(' tsstring 1 "2009-09-30 10:00:00" 2 "2009-09-30 10:15:00" 3 "2009-09-30 10:35:00" 4 "2009-09-30 10:45:00" 5 "2009-09-30 11:00:00" '), as.is=TRUE, header=TRUE) R> ts <- strptime(Q$tsstring, "%Y-%m-%d %H:%M:%S", tz="UTC") if I try to store the datetime column into the data.frame, I get a curious error: R> Q$ts <- ts Error in `

How to make time difference in same units when subtracting POSIXct

心不动则不痛 提交于 2019-11-27 14:41:34
I want to subtract to POSIXct. I can do this but depending on the first row (i guess?) the difference will be in seconds or minutes. Below you can see the first diff is in seconds and the second diff is in minutes because I changed the time difference in the first row: #diff in seconds because 1st row time diff is small? t1<- as.POSIXct(c("2015-02-02 20:18:03 00:00:00", "2015-02-02 20:17:02 00:00:00"),"GMT") t2<- as.POSIXct(c("2015-02-02 20:18:02 00:00:00","2015-02-02 20:18:02 00:00:00"),"GMT") d<-data.frame(t1= t1, t2= t2) d$t1-d$t2 #diff in seconds because 1st row time diff is larger? t1<-