xts

Is there a work around for slow performance of do.call(cbind.xts,…) in R 2.15.2?

ぃ、小莉子 提交于 2019-11-30 19:55:50
I would expect cbind.xts and do.call(cbind.xts) to perform with similar elapsed time. That was true for R2.11, R2.14. For R2.15.2 and xts 0.8-8, the do.call(cbind.xts,...) variant performs drastically slower , which effectively breaks my previous codes. As Josh Ulrich notes in a comment below, the xts package maintainers are aware of this problem. In the meantime, is there a convenient work around? Reproducible example: library(xts) secs <- function (rows, from = as.character(Sys.time()), cols = 1, by = 1) { deltas <- seq(from = 0, by = by, length.out = rows) nacol <- matrix(data = NA, ncol =

data.table time subset vs xts time subset

*爱你&永不变心* 提交于 2019-11-30 17:03:36
问题 Hi I am looking to subset some minutely data by time. I normally use xts doing something like: subset.string <- 'T10:00/T13:00' xts.min.obj[subset.string] to get all the rows which are between 10am and 1pm (inclusive) EACH DAY and have the output as an xts format. But is a bit slow for my purposes...e.g j <- xts(rnorm(10e6),Sys.time()-(10e6:1)) system.time(j['T10:00/T16:00']) user system elapsed 5.704 0.577 17.115 I know that data.table is v fast and at subsetting large datasets so am

R - Stock market data from csv to xts

懵懂的女人 提交于 2019-11-30 16:14:17
问题 I have this data in a CSV: Date ALICORC1 ALT ATACOBC1 AUSTRAC1 CONTINC1 BVN DNT 40886 5.8 0.1 0.9 0.28 5.45 38.2 1.11 40889 5.8 0.1 0.88 0.28 5.37 37.7 1.04 40890 5.8 0.09 0.87 0.27 5.33 37.4 0.99 40891 5.7 0.1 0.85 0.27 5.3 37.5 0.91 These are stock closing prices from the Peruvian Stock Market, and I want to convert them to xts so I can find the optimal portfolio and other stuff, but I can't find the way to convert this CSV to xts. I've checked out the answer to many of the questions here

Set frequency in xts object

扶醉桌前 提交于 2019-11-30 16:13:13
I want to create an xts object in R, which I then want to decompose to seasonal and trend. > require(xts) > require(lubridate) > chicos$date <- ymd(chicos$date) > ctr.ts <- xts(chicos[, 7], order.by = chicos[, 8], frequency = 365) > plot(ctr.ts, main="Meaningful title") When I try to decompose it, I get this error message.. > plot(decompose(ctr.ts)) Error in decompose(ctr.ts) : time series has no or less than 2 periods My observations are daily, and span from 2014-12-01 to 2015-02-25. Did I set the wrong frequency ? For the frequency of the time series of type xts: By default xts has a daily

to.minutes using custom endpoints

青春壹個敷衍的年華 提交于 2019-11-30 10:05:11
I am using intra-day data that starts at 9:50am and would like to convert it into 20 minute time intervals so the first period would be from 09:50 to 10:09:59 and the second time period would be from 10:10 to 10:29:59 etc. However to.minutes() from the xts package seems to fix it onto the hours and the has time bars at 09:59:59 and 10:19:59 etc...i.e. it is 10 minutes out... i know its probably not a regular request...but is there anyway of doing this so that it has the correct endpoints, i.e. basing it upon the frist timestamp? and for bonus points...is there a way to do do it based on the

Convert daily to weekly/monthly data with R

我是研究僧i 提交于 2019-11-30 07:02:30
问题 I have daily prices series over a wide range of products; I want to convert to a new dataframe with weekly or monthly data. I first used xts in order to apply the to.weekly function...which works only for OHLC format. I am sure there may exist a function similar to to.weekly but for dataframe where the format is not OHLC. There a different posts already related to this as the following: Does rollapply() allow an array of results from call to function? or Averaging daily data into weekly data

data.table time subset vs xts time subset

爷,独闯天下 提交于 2019-11-30 05:51:44
问题 Hi I am looking to subset some minutely data by time. I normally use xts doing something like: subset.string <- 'T10:00/T13:00' xts.min.obj[subset.string] to get all the rows which are between 10am and 1pm (inclusive) EACH DAY and have the output as an xts format. But is a bit slow for my purposes...e.g j <- xts(rnorm(10e6),Sys.time()-(10e6:1)) system.time(j['T10:00/T16:00']) user system elapsed 5.704 0.577 17.115 I know that data.table is v fast and at subsetting large datasets so am

Why is there no apply.hourly in R with xts/zoo?

走远了吗. 提交于 2019-11-30 05:25:11
I want to aggregate data by hourly mean. Daily is very easy: apply.daily(X2,mean) Why is there no function for hourly? I tried hr.means <- aggregate(X2, format(X2["timestamp"],"%Y-%m-%d %H")) and got always error with trim argument. Is there an easier function similar to apply.daily? What if I want to aggregate the mean of 5 minutes. Data are values per minute: "timestamp", value "2012-04-09 05:03:00",2 "2012-04-09 05:04:00",4 "2012-04-09 05:05:00",5 "2012-04-09 05:06:00",0 "2012-04-09 05:07:00",0 "2012-04-09 05:08:00",3 "2012-04-09 05:09:00",0 "2012-04-09 05:10:00",1 I am using xts and zoo.

Grouping every n minutes with dplyr

守給你的承諾、 提交于 2019-11-30 05:07:54
I have a dataset containing 10 events occuring at a certain time on a given day, with corresponding value for each event: d1 <- data.frame(date = as.POSIXct(c("21/05/2010 19:59:37", "21/05/2010 08:40:30", "21/05/2010 09:21:00", "21/05/2010 22:29:50", "21/05/2010 11:27:34", "21/05/2010 18:25:14", "21/05/2010 15:16:01", "21/05/2010 09:41:53", "21/05/2010 15:01:29", "21/05/2010 09:02:06"), format ="%d/%m/%Y %H:%M:%S"), value = c(11313,42423,64645,643426,1313313,1313,3535,6476,11313,9875)) I want to aggregate the results every 3 minutes, in a standard dataframe format (from "21/05/2010 00:00:00"

Is there a work around for slow performance of do.call(cbind.xts,…) in R 2.15.2?

余生长醉 提交于 2019-11-30 03:52:58
问题 I would expect cbind.xts and do.call(cbind.xts) to perform with similar elapsed time. That was true for R2.11, R2.14. For R2.15.2 and xts 0.8-8, the do.call(cbind.xts,...) variant performs drastically slower , which effectively breaks my previous codes. As Josh Ulrich notes in a comment below, the xts package maintainers are aware of this problem. In the meantime, is there a convenient work around? Reproducible example: library(xts) secs <- function (rows, from = as.character(Sys.time()),