xts

getSymbols (quantmod) giving wrong dates

孤街醉人 提交于 2019-12-10 16:17:30
问题 I'm using the quantmod package to fetch stock data. The code Data = getSymbols('LON:ADN',src="google",auto.assign=FALSE, from = '2011-08-10') Results in an xts as expected, however on closer examination it shows a volume of trades for 2012-10-21 (October 21st) which was a sunday, and is therefore clearly erroneous. Several other sundays are also included. Unfortunately the errors surrounding the weekends seem to have moved the rest of the data out of alignment. Has anyone experienced similar

merged xts object are not aligned

廉价感情. 提交于 2019-12-10 15:54:47
问题 please, try the following code: library(quantmod) getSymbols('SPY', from = '1950-01-01') SPY <- to.monthly(SPY) temp <- xts(Cl(SPY), index(SPY)) You will obtain a xts object which has the same length of Cl(SPY) and the same dates... or it should be so. If you input merge(Cl(SPY), temp) you will see that, although Cl(SPY) and temp have the same index date, they are not aligned, the code produces doubles and a lot of NA s. How may I merge them in a correct way? 回答1: This has been fixed in xts

xts split by week function specify first day of week as Sunday instead of default of Monday

依然范特西╮ 提交于 2019-12-10 14:57:23
问题 Applying the split function to a xts object by weeks groups rows into weekly chunks. The default days in the group are Monday to Sunday . What do I do if I want the days in the group to be from Sunday to Saturday ? library(xts) idx <- as.Date("2018-3-1") + 0:14 v <- 1:15 x <- xts(v, idx) group <- split(x, f = 'weeks') group Output: [[1]] [,1] 2018-03-01 1 # Thursday 2018-03-02 2 # Friday 2018-03-03 3 # Saturday 2018-03-04 4 # Sunday [[2]] [,1] 2018-03-05 5 # Monday 2018-03-06 6 # Tuesday 2018

Why can't I boxplot an xts directly?

﹥>﹥吖頭↗ 提交于 2019-12-10 14:14:19
问题 > x <- data.frame(a = rnorm(10), b = rnorm(10), c = rnorm(10)) > x a b c 1 -1.09651022 -0.7416278 0.209405373 2 1.53644398 -0.9463432 0.374955227 3 1.71132675 -0.3828052 2.024143398 4 -1.10622882 -0.3599187 -0.808780103 5 -0.49616562 0.7061180 0.644142118 6 -1.75452442 0.3890812 -0.623815889 7 0.06315648 0.5103820 -1.501873998 8 0.64856129 -1.0973679 1.432024595 9 -0.62828873 -0.3159317 0.183674189 10 -0.82657934 1.6376569 -0.003601196 > rownames(x) <- as.Date(Sys.Date() - 9:0) > x a b c 2013

No applicable method for 'time<-' applied to an object of class “c('xts', 'zoo')” [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-10 13:37:16
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . Please, put this data structure into R in order to reproduce my example: dX <- structure(c(3272.1, 3271.48, 3281.03, 3267.08, 3260.65, NA, 1616.3, 1620.1

Split xts object by specified irregular intervals in R

旧城冷巷雨未停 提交于 2019-12-10 13:11:28
问题 I want to split a daily xts object into 4 separate weeks which correspond to the following days in the month: 1st-7th, 8th-14th, 15th-21st, and 22nd to the end of the month, where the last week will generally be longer (but that's okay!). Here's some example code of an xts object for January 2004 created from a sequence of dates: week <- seq(from=as.Date("2004-01-01"), to=as.Date("2004-01-31"), by = "day") x2 <- sample(1:50, 31) # generating 31 random numbers January_series <- xts(x2, order

R - Next highest value in a time series

一笑奈何 提交于 2019-12-10 12:12:37
问题 A relatively simple question, but one I can't seem to find any examples. I have simple forex price data which is in a 2 column xts object called subx1: Datetime, Price 2016-09-01 00:00:01, 1.11563 2016-09-01 00:00:01, 1.11564 2016-09-01 00:00:02, 1.11564 2016-09-01 00:00:03, 1.11565 ... and so forth. I'm trying to find the first time after 2pm when the price goes higher than the pre-2pm high which is held in another object's column called daypeakxts$before2.High and Where a sample of

R: Why an xts object becomes a zoo object after calling transform()?

怎甘沉沦 提交于 2019-12-10 11:32:11
问题 transform() removes the class "xts" qualifier from my xts object: > class(myxts) [1] "xts" "zoo" > myxts = transform(myxts, ABC = 1) > class(myxts) [1] "zoo" Why is that? 回答1: There's no xts method for transform , so the zoo method is dispatched. The zoo method explicitly creates a new zoo object. > zoo:::transform.zoo function (`_data`, ...) { if (is.null(dim(coredata(`_data`)))) warning("transform() is only useful for matrix-based zoo series") zoo(transform.data.frame(data.frame(coredata(`

irregular time series data- can I make it regular? in r

百般思念 提交于 2019-12-10 11:29:16
问题 I have data that was programmed to acquire information every 5 hours which means multiple data points per day. The problem is sometimes the data logger fails or batteries die or whatever and there are missing data or failed attempts. All of my analysis I do is based upon these dates. I need to sort and filter and select everything based on this date/time stamp. As of right now I am going through "long winded" scripts just to select and subset my data. Additionally I have several data loggers

Error with xts::apply: “Error in coredata.xts(x) : currently unsupported data type”

社会主义新天地 提交于 2019-12-10 10:09:48
问题 The error occurred to me When I was trying to do the following work: # generate random integrals # data <- xts(floor(runif(100, 1,101)),as.Date("1973-02-01") + c(1:100) - 1) apply.monthly(data, diff,1,1) , while this one works: apply.monthly(data,mean) I have checked similar questions posted, but it seems they do not apply to the situation here. Any advice? Some further explanation: The reason I need this is that I got a time series data set like the following, 1990-05 100 1990-04 80 1990-03