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
2 answers

Plot multiple time series with different time indices in R using xts

Using R, I have a several time series and they have different time indices, like date.a<-seq(as.Date('2014-01-01'),as.Date('2014-02-01'),by = 2) date.b<-seq(as.Date('2014-01-01'),as.Date('2014-02-15'),by = 3) df.a <- data.frame(time=date.a,…
Roland
  • 517
  • 8
  • 25
1
vote
2 answers

Issues with calling for specific info from symbols held in a list in R

START <- '2013-09-03' symbolList <- list("AAPL", "MSFT", "TSLA", "GOOG", "IBM") for (ii in 1:length(symbolList)) { getSymbols(paste(symbolList[ii]), src='yahoo', from=START) } This will generate 5 xts objects, each with 6 columns. I want…
DolemiteMofo
  • 39
  • 1
  • 6
1
vote
1 answer

subtracting dates with standardised result

I am subtracting dates in xts i.e. library(xts) # make data x <- data.frame(x = 1:4, BDate = c("1/1/2000 12:00","2/1/2000 12:00","3/1/2000 12:00","4/1/2000 12:00"), CDate = c("2/1/2000 12:00","3/1/2000 12:00","4/1/2000…
user1320502
  • 2,510
  • 5
  • 28
  • 46
1
vote
1 answer

subset xts up to but NOT including subset date OR in POSIXct

Some example data..... library(xts) ref <- data.frame(Date = c("2/1/2000")) frame <- read.table(text = " x Date Time a 1/1/2000 5:00 a 1/1/2000 18:00 …
user1320502
  • 2,510
  • 5
  • 28
  • 46
1
vote
1 answer

Using 'PerformanceAnalytics' package to calculate Performance Measures

I need to use 'PerformanceAnalytics' package of R and to use this package, I understand that I need to convert the data into xts data, which is actually a panel data. Following this forum's suggestion I have done the following: library(foreign) RNOM…
Jairaj Gupta
  • 347
  • 4
  • 16
1
vote
2 answers

Trouble creating xts

For some reason I am having issues creating a time series object. Example below: dat = read.csv("latency.csv", header = FALSE) x <- dat[1:10,1:2] x V1 V2 1 08:48:17 85.258 2 08:48:17 39.471 3 09:00:02 11.645 4 09:00:02 39.380 5 …
E.D.
  • 319
  • 1
  • 5
  • 15
1
vote
1 answer

How to extract dates from apply.monthly function

If I have a set of daily data, I want to get the minimum value for each month, and the date on which that value occurred. If I use the apply.monthly function, it gives me the minimum value, but the corresponding date is the end of every month, not…
Bomhof
  • 305
  • 1
  • 2
  • 5
1
vote
1 answer

Calculate return row by row for a xts time series

I want basically to calculate a cumulative return (and an Index value) for a xts time series for which I have a return for each period. But since I'm looking at defined periods to compare these time series I want the cumulative return and Index…
MichiZH
  • 5,587
  • 12
  • 41
  • 81
1
vote
1 answer

Can order output in rows instead of columns?

In the following code I use apply & order to give a relative rank, by row, of the strength of the 10 elements in each row of MyData. There are 16 rows and the dimension of MyData is 16x10 with dates (the xts index) vertically. The output of my…
LGTrader
  • 2,349
  • 4
  • 23
  • 29
1
vote
1 answer

R: Currently unsupported data type when using period.apply

First a reproducible example: library(quantstrat) getSymbols("AAPL") Test<-period.apply(AAPL,endpoints(AAPL,on="weeks",k=10),ROC) TestDF<-as.data.frame(Test) I want to get the ROC for a certain stock or whatever for x weeks. Or in other words, I…
MichiZH
  • 5,587
  • 12
  • 41
  • 81
1
vote
1 answer

Prepend xts rows to a subset

Supposing I need to apply an MA(5) to a batch of market data, stored in an xts object. I can easily pull the subset of data I wanted smoothed with xts subsetting: x['2013-12-05 17:00:01/2013-12-06 17:00:00'] However, I need an additional 5…
khoxsey
  • 1,405
  • 9
  • 13
1
vote
1 answer

XTS object with chr data

I simply download time series from Bloomberg and try to make an xts object: library(Rbbg) conn <- blpConnect() tickers = c("SPX Index","GX1 Index","VG1 Index","NK1 Index", "SM1 Index","RM1 Index","LT01TRUU Index") df <-…
Fryc
  • 93
  • 1
  • 1
  • 7
1
vote
1 answer

Read a list to get name of xts object

I'm trying to work through a version of Guy Yonlin's excellent example code for quantstrat & blotter but make it work for a set of portfolios. Unfortunately I'm stuck trying to read a list of symbols and get R to access the actual xts data that got…
LGTrader
  • 2,349
  • 4
  • 23
  • 29
1
vote
2 answers

R: Confusion with date column when converting from xts to dataframe

I want to try ggplot with some time series data (stocks) and would like to pass x and y axis values to the ggplot function. Here's my sample code: require(quantmod) getSymbols("AAPL") AAPL.DF<-as.data.frame(AAPL) Interesting is here that we have…
MichiZH
  • 5,587
  • 12
  • 41
  • 81
1
vote
1 answer

chron to xts - keep date-time format

I have a data frame data that looks like this: dim(data) # [1] 66955 2 library(chron) data <- structure(list(`Date-Time` = structure(c(11320.6592476852, 11320.6661921296, 11324.3958564815, 11324.4022569444), format = structure(c("y/m/d",…