posixct

Removing rows containing specific dates in R

你说的曾经没有我的故事 提交于 2021-02-18 19:34:40
问题 Disclaimer: I am going to come out of this looking silly. I have a data frame containing a column which has a date of class POSIXct . I am trying to remove some of the rows containing specific dates- public holidays. I tried to do that using this: > modelset.nonholiday <- modelset[!modelset$date == as.POSIXct("2013-12-31")| !modelset$date ==as.POSIXct("2013-07-04") | !modelset$date == as.POSIXct("2014-07-04")| !modelset$date == as.POSIXct ("2013-11-28") | !modelset$date == as.POSIXct ("2013

Removing rows containing specific dates in R

我只是一个虾纸丫 提交于 2021-02-18 19:33:47
问题 Disclaimer: I am going to come out of this looking silly. I have a data frame containing a column which has a date of class POSIXct . I am trying to remove some of the rows containing specific dates- public holidays. I tried to do that using this: > modelset.nonholiday <- modelset[!modelset$date == as.POSIXct("2013-12-31")| !modelset$date ==as.POSIXct("2013-07-04") | !modelset$date == as.POSIXct("2014-07-04")| !modelset$date == as.POSIXct ("2013-11-28") | !modelset$date == as.POSIXct ("2013

How do I plot time (HH:MM:SS) in X axis in R

这一生的挚爱 提交于 2021-02-18 12:43:05
问题 I have tried to read through stackoverflow, blogs, books etc but have been unable to find the answer on plotting time in the x-axis in the following format(HH:MM:SS.000) in R and another quantity on the y-axis. I have the following dataset: Time EcNo 12:54:09.000 -14.47 12:54:10.000 -17.96 12:54:11.000 -15.97 12:54:12.000 -14.61 12:54:13.000 -12.68 12:54:14.000 -10.73 12:54:15.000 -10.54 12:54:16.000 -11.62 12:54:17.000 -12.49 12:54:18.000 -11.12 How would I plot EcNo on Yaxis vs Time(x axis)

R - convert POSIXct to fraction of julian day

假装没事ソ 提交于 2021-02-16 14:46:41
问题 How can a date/time object in R be transformed on the fraction of a julian day? For example, how can I turn this date: date <- as.POSIXct('2006-12-12 12:00:00',tz='GMT') into a number like this > fjday [1] 365.5 where julian day is elapsed day counted from the january 1st. The fraction 0.5 means that it's 12pm, and therefore half of the day. This is just an example, but my real data covers all the 365 days of year 2006. 回答1: Since all your dates are from the same year (2006) this should be

how to convert a very large dataset to xts? - as.xts fails on 1.5M rows

梦想的初衷 提交于 2021-02-10 18:43:23
问题 I have the data: dput(head(data)) > dput(head(data)) structure(list(Gmt.time = c("01.06.2015 00:00", "01.06.2015 00:01", "01.06.2015 00:02", "01.06.2015 00:03", "01.06.2015 00:04", "01.06.2015 00:05" ), Open = c(0.88312, 0.88337, 0.88377, 0.88412, 0.88393, 0.8838 ), High = c(0.88337, 0.88378, 0.88418, 0.88418, 0.88393, 0.88393 ), Low = c(0.883, 0.88337, 0.88374, 0.88394, 0.88368, 0.88362 ), Close = c(0.88337, 0.88375, 0.88412, 0.88394, 0.8838, 0.88393 ), Volume = c(83.27, 100.14, 117.18, 52

how to convert a very large dataset to xts? - as.xts fails on 1.5M rows

别来无恙 提交于 2021-02-10 18:41:49
问题 I have the data: dput(head(data)) > dput(head(data)) structure(list(Gmt.time = c("01.06.2015 00:00", "01.06.2015 00:01", "01.06.2015 00:02", "01.06.2015 00:03", "01.06.2015 00:04", "01.06.2015 00:05" ), Open = c(0.88312, 0.88337, 0.88377, 0.88412, 0.88393, 0.8838 ), High = c(0.88337, 0.88378, 0.88418, 0.88418, 0.88393, 0.88393 ), Low = c(0.883, 0.88337, 0.88374, 0.88394, 0.88368, 0.88362 ), Close = c(0.88337, 0.88375, 0.88412, 0.88394, 0.8838, 0.88393 ), Volume = c(83.27, 100.14, 117.18, 52

R POSIXct returns NA with “03/12/2017 02:17:13”

落爺英雄遲暮 提交于 2021-02-10 06:01:16
问题 I have a data set containing the following date, along with several others 03/12/2017 02:17:13 I want to put the whole data set into a data table, so I used read_csv and as.data.table to create DT which contained the date/time information in date. Next I used DT[, date := as.POSIXct(date, format = "%m/%d/%Y %H:%M:%S")] Everything looked fine except I had some NA values where the original data had dates. The following expression returns an NA as.POSIXct("03/12/2017 02:17:13", format = "%m/%d/

as.Date() does not respect POSIXct time zones

大憨熊 提交于 2021-02-08 13:49:12
问题 Okay so here is a subtle "quirk" in the r as.Date function converting from a POSIXct with a timezone, which I am wondering if it is a bug. > as.POSIXct("2013-03-29", tz = "Europe/London") [1] "2013-03-29 GMT" > as.Date(as.POSIXct("2013-03-29", tz = "Europe/London")) [1] "2013-03-29" So far no problem, but..... > as.POSIXct("2013-04-01", tz = "Europe/London") [1] "2013-04-01 BST" > as.Date(as.POSIXct("2013-04-01", tz = "Europe/London")) [1] "2013-03-31" Anybody seen this? Is this a bug or

Reliable way to detect if a column in a data.frame is.POSIXct

孤人 提交于 2021-02-04 14:22:05
问题 R has is.vector , is.list , is.integer , is.double , is.numeric , is.factor , is.character , etc. Why is there no is.POSIXct , is.POSIXlt or is.Date ? I need a reliable way to detect POSIXct object, and class(x)[1] == "POSIXct" seems really... dirty. 回答1: I would personally just use inherits as joran suggested. You could use it to create your own is.POSIXct function. # functions is.POSIXct <- function(x) inherits(x, "POSIXct") is.POSIXlt <- function(x) inherits(x, "POSIXlt") is.POSIXt <-

Re-aggregating data - from coarse to finer temporal resolution

帅比萌擦擦* 提交于 2021-01-29 06:09:20
问题 I would like to follow-up on a question answered by @r2evans: Interpolation in R: retrieving hourly values. I am trying to re-aggregate 3-hr data into hourly. If I use the following small reproducible dataset ("tair"): tair<-structure(list(Year = c(1991L, 1991L, 1991L, 1991L, 1991L, 1991L, 1991L, 1991L), Month = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), DoY = c(1L,1L, 1L, 1L, 1L, 1L, 1L, 2L), Hour = c(3L, 6L, 9L, 12L, 15L, 18L, 21L, 0L), Kobb = c(3.032776, 3.076996, 3.314209, 1.760345, 1.473724,1