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

ggplot2: yearmon scale and geom_bar

More than a solution I'd like to understand the reason why something which should be quite easy, it's actually not. [I am borrowing part of the code from a different post which touched on the issue but it ended up with a solution I didn't…
Matteo Castagna
  • 472
  • 3
  • 13
8
votes
2 answers

Dynamically add column to xts object

Adding a column to an xts object is straightforward if you know the name of the column ahead of time. For example, to add a column named "b": n <- 5 x <- merge(xts(order.by = as.Date('2015-1-1') + 1:n), a = rnorm(n)) x$b <- rnorm(n) Adding a…
banbh
  • 1,331
  • 1
  • 13
  • 31
8
votes
2 answers

Animate map in R with leaflet and xts

I would like to build an animated map with a time cursor in R. I have time series (xts) that I would like to represent on map. library(xts) library(leaflet) date<-seq(as.POSIXct("2015-01-01"), as.POSIXct("2015-01-10"),…
Felipe
  • 719
  • 8
  • 20
8
votes
0 answers

Can't convert a dataframe into an xts object anymore

I wrote a function to convert a dataframe into an xts object many months ago. It used to work and now, it doesn't work anymore. I don't know how to fix it. I have installed the xts package again with no avail. I searched stackoverflow and googled…
user3602239
  • 671
  • 5
  • 15
8
votes
2 answers

which time series class to use in R for financial data?

for working with financial time series, like daily stock prices or intraday data, which time series packages are preferred? xts, plain zoo, or timeSeries or something else? I use both xts and zoo, but sometimes not sure to use xts exclusively or…
ahala
  • 81
  • 2
8
votes
2 answers

Use dygraph for R to plot xts time series by year only?

I am trying to use the new dygraphs for R library to plot winning times for men and women in the Boston Marathon each year. I've got a data frame of winning times by second, here's a portion of it: winners <- data.frame(year=1966:1971,…
Sharon
  • 3,676
  • 3
  • 23
  • 20
8
votes
3 answers

Check the frequency of time series data

Assume: I have a time series data, either a zoo or xts object. Question: Is there any convenient function or method so that I can check whether the time series is monthly, quarterly or yearly?
L.J
  • 1,066
  • 2
  • 13
  • 28
8
votes
4 answers

rowSums but keeping NA values

I am pretty sure this is quite simple, but seem to have got stuck...I have two xts vectors that have been merged together, which contain numeric values and NAs. I would like to get the rowSums for each index period, but keeping the NA values. Below…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
8
votes
2 answers

Add missing xts/zoo data with linear interpolation in R

I do have problems with missing data, but I do not have NAs - otherwise would be easier to handle... My data looks like this: time, value 2012-11-30 10:28:00, 12.9 2012-11-30 10:29:00, 5.5 2012-11-30 10:30:00, 5.5 2012-11-30 10:31:00, 5.5 2012-11-30…
Herr Student
  • 853
  • 14
  • 26
8
votes
3 answers

How to handle 'Series contains non-leading NAs' in TTR library with xts objects?

I often run into the same issue of how to handle NA values when modelling quantitative trading models. The example below is about a stock with EOD data since 1997-01-01 stored in a xts object with four columns named "High","Low","Close","Volume".…
P. Garnry
  • 344
  • 1
  • 6
  • 12
8
votes
1 answer

ggplot2: highlight chart area

I am working with some time series data and would like to highlight chart area whenever certain conditions become true. For example: require(ggplot2) require(quantmod) initDate <- "1993-01-31" endDate <- "2012-08-10" symbols <-…
user1234440
  • 22,521
  • 18
  • 61
  • 103
8
votes
2 answers

Rolling regression over multiple columns

I have an issue finding the most efficient way to calculate a rolling linear regression over a xts object with multiple columns. I have searched and read several previously questions here on stackoverflow. This question and answer comes close but…
P. Garnry
  • 344
  • 1
  • 6
  • 12
8
votes
1 answer

quantstrat in R: Setting a date based exit signal

Much of quantstrat and the accompanying examples seem to be set around entering and exiting trades by crossing some kind of technical indicator. However, let's say you have an arbitrary indicator which you're using to trigger an entry to the trade,…
n.e.w
  • 1,128
  • 10
  • 23
8
votes
2 answers

Creating regular 15-minute time-series from irregular time-series

I have an irregular time-series (with DateTime and RainfallValue) in a csv file C:\SampleData.csv: DateTime,RainInches 1/6/2000 11:59,0 1/6/2000 23:59,0.01 1/7/2000 11:59,0 1/13/2000 23:59,0 1/14/2000 0:00,0 1/14/2000 23:59,0 4/14/2000…
akashwani
  • 105
  • 1
  • 1
  • 7
7
votes
4 answers

Replacement for diff() for multiple columns

diff() calculates the difference between values in a vector at a specified lag. Is there an equivalent function that works on two vectors? For example, I have: v1 = c(1, 2, 3, 4, 5, 3) v2 = c(5, 4, 3, 2, 1, 0) I need to calculate the difference…
Robert Kubrick
  • 8,413
  • 13
  • 59
  • 91