posixct

time zones in POSIXct and xts, converting from GMT in R

主宰稳场 提交于 2020-01-12 21:25:12
问题 I have a bunch of 1 minute returns in an xts object with the index being POSIXct and time zone being GMT. The returns are on NYSE so I would like to convert to the eastern time zone but I would like to take care of the daylight savings time properly. What is the best way of doing this? I am a bit confused between the EST timezone and the EDT timezone. I would like my times to convert properly to the NY time in winter and summer. 回答1: Use indexTZ<- and the America/New_York timezone > tail(SPY)

time zones in POSIXct and xts, converting from GMT in R

心已入冬 提交于 2020-01-12 21:25:10
问题 I have a bunch of 1 minute returns in an xts object with the index being POSIXct and time zone being GMT. The returns are on NYSE so I would like to convert to the eastern time zone but I would like to take care of the daylight savings time properly. What is the best way of doing this? I am a bit confused between the EST timezone and the EDT timezone. I would like my times to convert properly to the NY time in winter and summer. 回答1: Use indexTZ<- and the America/New_York timezone > tail(SPY)

05:00:00 - 28:59:59 time format function

旧时模样 提交于 2020-01-07 08:22:31
问题 I want to create function wich handles question: 05:00:00 - 28:59:59 time format When I run script from that question it's working but when I run the function: pal <- NormalDates(data,Date,Time.start) Error in unclass(e1) + unclass(e2) : non-numeric argument to binary operator Called from: `+.POSIXt`(as.POSIXct(as.character(df$day), format = "%d.%m.%Y"), sapply(strsplit(as.character(df$time), ":"), function(t) { t <- as.integer(t) t[3] + t[2] * 60 + t[1] * 60 * 60 })) Browse[1]> How can I get

05:00:00 - 28:59:59 time format function

眉间皱痕 提交于 2020-01-07 08:22:05
问题 I want to create function wich handles question: 05:00:00 - 28:59:59 time format When I run script from that question it's working but when I run the function: pal <- NormalDates(data,Date,Time.start) Error in unclass(e1) + unclass(e2) : non-numeric argument to binary operator Called from: `+.POSIXt`(as.POSIXct(as.character(df$day), format = "%d.%m.%Y"), sapply(strsplit(as.character(df$time), ":"), function(t) { t <- as.integer(t) t[3] + t[2] * 60 + t[1] * 60 * 60 })) Browse[1]> How can I get

Converting Character String to Datetime

天大地大妈咪最大 提交于 2020-01-07 06:17:06
问题 I am trying to load a dataset into r and change the type of a column into datetime. strptime , as.POSIXct or as.Date for different cases should work; This is my code: a <- structure(list(DATE = c("01/01/2011 12:00:00", "01/02/2011 12:00:00", "01/03/2011 12:00:00", "01/04/2011 12:00:00", "01/05/2011 12:00:00", "01/06/2011 12:00:00"), VAL = c(65.34447917, 65.23983333, 65.03183333, 64.89107292, 64.83333333, 64.848625), id = c("VT1-1", "VT1-1", "VT1-1", "VT1-1", "VT1-1", "VT1-1")), .Names = c(

creating dummy variable based on event date within certain time-period

喜你入骨 提交于 2020-01-06 03:20:05
问题 I have a dataset products like so: > head(featured_products) Dept Class Sku Description Code Vehicle/Placement StartDate EndDate Comments(Circulation,Location,etc) 1: 430 4318 401684 ++INDV RAMEKIN WP 9CM OSM Facebook 2017-01-01 2017-01-29 Fancy Brunch Blog 2: 430 4318 401684 ++INDV RAMEKIN WP 9CM OSM Twitter 2017-01-01 2017-01-29 Fancy Brunch Blog 3: 340 3411 1672605 ++ SPHERE WILLOW 4" OP1 Editorial 2016-02-29 2016-03-27 Spruce up for Spring 4: 230 2311 2114074 ++BOX 30 ISLAND ORCHRD

How does character comparison work in R?

点点圈 提交于 2020-01-04 06:05:37
问题 I used to use string comparisons directly in my code without giving it much of a thought. I then recently found that something is off here as though it worked for say > "1" < "2" [1] TRUE It failed for > "6" < "10" [1] FALSE I think there is a very simple explanation for this and I am just being dumb. Maybe it compares their ASCII values or something. Any insights? The reason I ask is I am planning on sorting a vector of timestamps which are of class character. Example : > timeStamps <- c(

R time_trans works with objects of class POSIXct

不打扰是莪最后的温柔 提交于 2020-01-04 03:50:27
问题 I have data with stock prices(data). Stock data I would like to visualize it. I first use ggplot R plotting to visualize the series. Date Closed 2010-07-19 0.0808 2010-07-20 0.7547 When I used below code my_date_format <- function() { function(x) { m <- format(x,"%b") y <- format(x,"%Y") ifelse(duplicated(y),m,paste(m,y)) } } ggplot(data, aes(x=Date, z=Closed)) + geom_point() + scale_x_datetime(breaks = date_breaks("1 month"), labels=my_date_format()) I had an error: Error: Invalid input:

How to most efficiently convert a character string of “01 Jan 2014” to POSIXct i.e. “2014-01-01” yyyy-mm-dd

时光毁灭记忆、已成空白 提交于 2020-01-03 19:18:11
问题 I already have a partial answer to the problem here, which I understand as far as it is explained: How to most efficiently restructure a character string for fasttime in data.table However, the task has been extended, and needs to deal with a variation of the orginal formatting. I have a large dataset, with a column of dates of character class in the form of: 01 Jan 2014 or: dd MMM yyyy Which I want to restructure to feed into fastPOSIXct which only accepts character input in POSIXct order:

Error reading timestamps using “xlsx” package

こ雲淡風輕ζ 提交于 2020-01-02 14:33:51
问题 Data in Excel file looks like TIMESTAMP TYPE BID BIDSIZ 2015-01-04 09:00:00 BID 365 10 2015-04-01 09:00:05 BID 367.8 55 2015-04-01 09:00:33 BID 365 10 2015-04-01 09:00:36 BID 367.8 55 When I run the following code: require(xlsx) f1<-read.xlsx2("Canara_Data.xlsx", sheetName = "BID") f1$TIMESTAMP<-as.POSIXct(f1$TIMESTAMP, format="%Y-%M-%D %H:%M:S") viewing it causes TIMESTAMP to look like View(`f1`) TIMESTAMP X. BID BIDSIZ 42008.375 BID 365 10 42095.37505787037 BID 367.8 55 42095.37538194445