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
1
vote
1 answer

"Argument is of length 0" when comparing xts objects

This must be very simple, but I can't seem to find the solution. I need to compare the Close value for 2 xts objects I have 2 xts objects: >low2 low2 daco.Close 2013-07-24 6.63 >low3 low3 daco.Close 2013-07-24 2.63 But…
JordanBelf
  • 3,208
  • 9
  • 47
  • 80
1
vote
1 answer

Testing multiple columns in a time series simultaneously

library("xts") data1<- cbind(a = c(1,2,3,4,5,6,5,4,3,4,5,6,5,4,3,5), b = c(1,2,3,4,5,6,5,4,3,4,5,6,5,4,3,5), c = c(1,2,3,4,5,6,5,4,5,4,5,4,5,4,5,2), d = c(1,2,3,4,5,6,5,4,1,1,1,1,1,2,3,2)) data<- xts(data1,…
Ashish Jalan
  • 181
  • 8
1
vote
1 answer

Storing function returns in a table in R (quant finance)

For the purposes of this question, I would like to construct a data frame or similar to be able to "stack rank" and sort various metrics that are generated from functions. Let's take an example from the Performance Analytics package: I have the…
n.e.w
  • 1,128
  • 10
  • 23
1
vote
0 answers

Read multiple cvs files & merge columns

I am struggling to come up with a R script to read multiple stock price (OHLCV) cvs files and only pick up the Close column then merge into a single matrix xts time series with colnames of each stocks and column of Close prices series. I managed to…
Hao
  • 59
  • 6
1
vote
2 answers

R xts of factors

I would like to have unique numeric factors as part of an xts, so that over time...each number refers to a specific factor, independent of time. To give an example, imagine a stock index that changes its constituents every day. We can simulate this…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
1
vote
1 answer

How to convert 10-minute time blocks to 1-minute intervals in R

I wish to convert 10-minute time blocks into 1-minute time blocks for a large vector. My datatime values are spaced at 10-minutes intervals, which represent a 10-minute time block ending at the given time stamp. Example data below: data<-…
Emily
  • 859
  • 5
  • 14
  • 31
1
vote
1 answer

Function to create xts object from keyboard input

I have lots of sales areas. Each one is a data.frame and I can create xts objects for each. This requires a line of code for each. I'd rather use a function to create on demand. I've tried using keyboard entry to create a character string, then…
felixmc
  • 516
  • 1
  • 4
  • 19
1
vote
1 answer

construct dates (perhaps POSIXct?) from YY,MM,DD numeric columns then merge with another xts object

I have one xts object, and another data frame with 3 columns (YY, MM, DD). I am trying to create / convert these three columns to some sort of date/time format so that I can merge it with an xts tables together. No luck at all. Columns YY,MM,D are…
simon
  • 139
  • 1
  • 1
  • 5
1
vote
1 answer

Non-comformable arrays error when using xts series in a logistic regression

I'm using xts time series, originally converted from type ts, in a logstic regression, but I get Error in `*.default`(x[good, , drop = FALSE], w) : non-conformable arrays Example: success <- as.xts(ts(sample(0:10, 100, replace=T), start=1970,…
Abiel
  • 5,251
  • 9
  • 54
  • 74
1
vote
1 answer

rolling computations in xts by month part2

I want to calculate the VaR at the end of a month with the historical method. My time series will start at the beginning of 2000 until now. The calculation should start lets say in 2005 to have enough data. There is a similar post rolling…
dansan566
  • 91
  • 1
  • 7
1
vote
1 answer

merge.xts performance with large number of columns

The function below takes a folder of CSV files (each file is a financial time series with datetime, open, high, low, close columns) and creates a single XTS object for each of the open, high, low, close prices, where each XTS column is an individual…
hendalst
  • 2,957
  • 1
  • 24
  • 25
1
vote
1 answer

specifying from/to in seq.POSIXt

I'm writing a function which does some data pre-processing, and one of the things I'm doing is creating a regularly spaced xts object. All of the examples I've seen use seq.POSIXt in a way similar to this: temp <- xts(, seq.POSIXt(from =…
tmakino
  • 618
  • 1
  • 5
  • 20
1
vote
2 answers

mean and sd of the day in R with xts

again I do have my df in xts and don't have names! (as far as I know there is no name anymore when setting as.POSIXct()): "2012-04-09 05:00:00",2 "2012-04-09 09:00:00",4 "2012-04-09 12:00:00",5 "2012-04-09 22:00:00",0 "2012-04-10…
Herr Student
  • 853
  • 14
  • 26
1
vote
2 answers

dailyReturn with xts object

I am having difficulty using dailyReturn function on an xts object with multiple return series. a<-Cl(getSymbols("INTC",auto.assign=FALSE)) b<-Cl(getSymbols("IBM",auto.assign=FALSE)) a<-merge(a,b) dailyReturn(a[,1]) #This works! dailyReturn(a) #Only…
zsljulius
  • 3,813
  • 8
  • 36
  • 61
1
vote
1 answer

Splitting xts series in a list of regular intervals

I want to split my large xts object in a list of regular one second periods containing all the observations of the original objects. The goal is to send each list element to nodes on my cluster for processing. I came up with this solution, which is…
Robert Kubrick
  • 8,413
  • 13
  • 59
  • 91