Questions tagged [xts]

xts is an R package that contains an eXtensible Time Series class and methods. xts extends and behaves like zoo.

xts is an package for analysis. It provides uniform handling of R's different time-based data classes by extending the package.

Repositories

Vignettes

Other resources

Related tags

1987 questions
7
votes
1 answer

xts error - order.by requires an appropriate time-based object

I can not resolve why error in simple creation of xts object xts(rep(0, NROW(TICK.NYSE)), order.by = index(TICK.NYSE)) Error in xts(rep(0, NROW(TICK.NYSE)), order.by = index(TICK.NYSE)) : order.by requires an appropriate time-based…
Samo
  • 2,065
  • 20
  • 41
7
votes
0 answers

am I using the wrong data type with predict.nnet() in R

My lack of understanding of R is causing me to grind to a halt in my work and seek your help. I'm looking to build a neural network from some time series data and then build a prediction using separate data and the model returned by the trained…
tfb
  • 267
  • 2
  • 11
7
votes
1 answer

How to add heatmap to quantmod::chart_Series?

I would like to plot heatmap(s) below quantmod::chart_Series(). How to add the below heatmap to chart_Series (or xts::plot.xts): library(quantmod) # Get data fro symbol from Google Finance symbol <- "SPY" src <- "google" from <-…
Samo
  • 2,065
  • 20
  • 41
7
votes
1 answer

R - Color or shade area between lines

I'm trying to replicate with R a chart I made on Excel, which should represent a 95% Confidence Interval (CI) around a time series forecast. The Excel chart looks like this: So, basically, the original historical time series and from a certain…
Riccardo
  • 337
  • 1
  • 2
  • 7
7
votes
2 answers

Translating time stamps (start, end) into time series data. Errors with align.time() and colnames

I am new to R, but after taking an intro course and playing with it a bit, I'm hopeful that it can 1) more elegantly solve my modelling objectives (compared to Excel, which is my backup plan) and 2) be a useful skill to take away from this project.…
George K
  • 73
  • 7
7
votes
3 answers

Why can't I boxplot an xts directly?

> 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…
Thomas Browne
  • 23,824
  • 32
  • 78
  • 121
7
votes
3 answers

Convert daily to weekly/monthly data with R

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…
saradi
  • 141
  • 1
  • 1
  • 7
7
votes
1 answer

How to generate regular xts periods from random time observations?

I have the following xts matrix: > options(digits.secs = 6) > set.seed(1234) > xts(1:10, as.POSIXlt(1366039619, tz="EST", origin="1970-01-01") + rnorm(10, 500000, 250000)/1000000) [,1] 2013-04-15 10:26:58.913576 …
Robert Kubrick
  • 8,413
  • 13
  • 59
  • 91
7
votes
3 answers

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

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…
Herr Student
  • 853
  • 14
  • 26
7
votes
4 answers

concatenating/ merging time series (in R)

I have to xts/zoo objects. each has measures of different variables over a different time span. I want to create a single time series comprising all measures at all times, with NAs for missing dates/variable combinations. how do I do…
amit
  • 3,332
  • 6
  • 24
  • 32
7
votes
4 answers

subsetting in xts using a parameter holding dates

I am familiar with the xts subsetting abilities. However, I can't find an elegant way to subset a parameterized range of dates. something like this: times = c(as.POSIXct("2012-11-03 09:45:00 IST"), as.POSIXct("2012-11-05 09:45:00…
zuuz
  • 859
  • 1
  • 12
  • 23
7
votes
1 answer

Using auto.arima on xts objects

I'm trying to run auto.arima on some xts data, but am getting the following error: library(quantmod) library(forecast) getSymbols('^GSPC',from='2000-01-01') auto.arima(GSPC$GSPC.Close) Error in dimnames(cd) <- list(as.character(index(x)),…
jaredwoodard
  • 897
  • 1
  • 7
  • 8
7
votes
1 answer

xts::period.apply and cumprod

I am trying to calculate cumulative product for subsets of xts object. Here is an example of what I want and a question whether this can be done faster/more elegant using period.apply or some other c++ based fast function? # install.packages("qmao",…
Samo
  • 2,065
  • 20
  • 41
7
votes
4 answers

Removing NA columns in xts

I have an xts in the following format a b c d e f ...... 2011-01-03 11.40 NA 23.12 0.23 123.11 NA ...... 2011-01-04 11.49 NA 23.15 1.11 111.11 NA …
lab_notes
  • 407
  • 5
  • 11
7
votes
2 answers

Splitting irregular time series into regular monthly averages - R

In order to establish seasonal effects on energy use, I need to align the energy use information that I have from a billing database with monthly temperatures. I'm working with a billing dataset that has bills of varying lengths and start and end…
bikeclub
  • 369
  • 2
  • 10