xts

Convert date-time format for use in xts

ぐ巨炮叔叔 提交于 2019-12-11 00:47:42
问题 I am trying to convert my data into an xts but I keep getting a "order.by requires an appropriate time-based object" error so I am trying to convert my date time into the correct format. My data looks like this: Date Time Value 20090202 9:30 1 20090202 9:31 2 20090202 9:32 3 20090202 9:33 4 20090202 9:34 5 20090202 9:35 6 I have done this as well: data.frame(cbind(theData$Date, theData$Time)) which yields: 1 2 20090202 09:30 20090202 09:31 20090202 09:32 20090202 09:33 20090202 09:34 20090202

Average number of seconds between two time observations

↘锁芯ラ 提交于 2019-12-10 22:31:10
问题 I have a irregular time index from an xts object. I need to find the average number of seconds between two time observations. This is the my sample data: dput(tt) structure(c(1371.25, NA, 1373.95, NA, NA, 1373, NA, 1373.95, 1373.9, NA, NA, 1374, 1374.15, NA, 1374, 1373.85, 1372.55, 1374.05, 1374.15, 1374.75, NA, NA, 1375.9, 1374.05, NA, NA, NA, NA, NA, NA, NA, 1375, NA, NA, NA, NA, NA, 1376.35, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1376.25, NA, 1378, 1376.5, NA, NA, NA, 1378, 1378, NA, NA,

R: index() or index.xts() changes the values of Date of a time series, why?

不羁岁月 提交于 2019-12-10 20:28:16
问题 I would like to extract the dates from a time series obtained using getSymbols but when I used the index / index.xts function the returned dates appear to be one day earlier. I cannot understand why this behavior happens in the following code. However, the intended behavior is to obtain a list of Date object corresponding to the one in the original time series. Here is the code, note the last date of the time series SPY is 24 Aug 2012 but the last value from the index(SPY) call is 23 Aug 2012

R - XTS: Get the first dates and values for each month from a daily time series with missing rows

岁酱吖の 提交于 2019-12-10 19:55:57
问题 I have a daily time series as a myxts xts object in R , with date format being d/m/y. Now, I want to reduce the original time series to one that only takes the first date and value for each month in the series. myxts[.indexmday(myxts) == 1] returns a series containing d/m/y with d = 1. My problem is that I need 1 data for each month and my problem is that my original series has some months with no date and data for the date 1st calendar date. How does I say to R if there is not such a date,

How to subset a data frame by the last day of each month

最后都变了- 提交于 2019-12-10 19:44:54
问题 I have a df : dates V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1999-05-31 66 65 64 63 62 61 60 59 58 57 1999-06-01 67 66 65 64 63 62 61 60 59 58 1999-06-02 68 67 66 65 64 63 62 61 60 59 1999-06-03 69 68 67 66 65 64 63 62 61 60 1999-06-04 70 69 68 67 66 65 64 63 62 61 1999-06-17 79 78 77 76 75 74 73 72 71 70 1999-06-18 80 79 78 77 76 75 74 73 72 71 1999-06-21 81 80 79 78 77 76 75 74 73 72 1999-06-22 82 81 80 79 78 77 76 75 74 73 1999-06-23 83 82 81 80 79 78 77 76 75 74 1999-06-24 84 83 82 81 80 79 78 77

R xts converts numbers to strings - why?

筅森魡賤 提交于 2019-12-10 19:18:22
问题 When I convert to a xts object, R changes the values from numbers to strings, which causes problems: timeseries <- xts(timeseries,as.POSIXct(timeseries$Date)) timeseries <- timeseries[endpoints(timeseries,ts_ret_freq)] This is the code in question. Why is this the case? It shouldnt be. Thanks in advance. 回答1: Because an xts object is essentially a matrix object. Hence all the columns of the xts will always be of same datatype (class) 来源: https://stackoverflow.com/questions/15635590/r-xts

Time series plot range

雨燕双飞 提交于 2019-12-10 19:06:14
问题 Hi am ploting a xts object: And I would like to extend the xlim til 30-february because I want to add the prediction from an Arima model: par(mfrow=c(1,1)) pred <- predict(try2, n.ahead = 1,se.fit=T) lim_sup <- pred$pred + 1.96 * pred$se lim_inf <- pred$pred - 1.96 * pred$se plot(heat["1996-02-01 00:00/1996-02-16 04:00"],type="l",main="Cross Validation") points(exp(pred$pred),col="blue",lwd=2) points(exp(lim_sup),lwd=2,col="green") points(exp(lim_inf),lwd=2,col="green") But I can not see any

split a time series by another irregular time series

╄→гoц情女王★ 提交于 2019-12-10 19:05:31
问题 I am trying to split several xts objects with one unique irregular time series. split.xts splits on days, minutes, seconds, etc. Using breakpoints requires vectors of equal length, which produces an error when I try to split my data. dd <- c("2014-02-23","2014-03-12", "2014-05-29") tt <- c("03:15:52", "03:49:17", "04:03:24", "05:30:19", "05:56:49", "06:14:04", "09:42:13", "11:57:25", "11:58:02", "12:12:49", "15:38:00", "15:44:21", "16:16:04") dt <- c(outer(dd,tt,paste)) xx <- as.xts(seq_along

zoo/xts microsecond read issue

白昼怎懂夜的黑 提交于 2019-12-10 18:52:12
问题 The data looks like Time Set1 Set2 10:19:38.551629 16234 16236 10:19:41.408010 16234 16236 10:19:47.264204 16234 16236 I am trying to load this into zoo. orig <- read.zoo("~/sample.txt",sep="",header=TRUE,index.column=1,format="%H:%M:%S.%6f") Error in read.zoo("~/sample.txt", sep = "", header = TRUE, index.column = 1, : index has 3 bad entries at data rows: 1 2 3 ... I have checked all the relevant posts 1. R issue with rounding milliseconds 2. Milliseconds puzzle when calling strptime in R 3

Convert data from csv file into “xts” object

橙三吉。 提交于 2019-12-10 17:12:16
问题 I have got CSV files which has the Date in the following format: 25-Aug-2004 I want to read it as an "xts" object so as to use the function "periodReturn" in quantmod package. Can I use the following file for the function? Symbol Series Date Prev.Close Open.Price High.Price Low.Price 1 XXX EQ 25-Aug-2004 850.00 1198.70 1198.70 979.00 2 XXX EQ 26-Aug-2004 987.95 992.00 997.00 975.30 Guide me with the same. 回答1: Unfortunately I can't speak for the ts part, but this is how you can convert your