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
0
votes
1 answer

Adding a symbol column to sample.xts coerces the coredata

I am following along with the FAQ here: https://joshuaulrich.github.io/xts/xts_faq.html I make this sample.xts sample.xts <- xts(1:6, as.POSIXct(c("2009-09-22 07:43:30", "2009-10-01 03:50:30", "2009-10-01 08:45:00", "2009-10-01 09:48:15", …
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
0
votes
1 answer

Format Data Frame with Date Index and Column to Consolidate Row Values into Each Month Category

I have a data.frame that has a date index which is replicated in the first column and has a number of different columns and corresponding rows containing data. Because the rows containing data (which are indexed to the date) can vary depending on…
js80
  • 385
  • 2
  • 11
0
votes
2 answers

How to find a value by date from a list with xts

I have a list with xts world list $`XX` return 2018-01-31 2.16 2018-02-28 2.06 2018-03-31 2.12 2018-04-30 2.41 2018-05-31 2.07 $`YY` return 2018-01-31 1.12 2018-02-28 0.06 2018-03-31 3.12 $`ZZ` …
Angelo
  • 41
  • 4
0
votes
0 answers

Calculate rolling yearly differences in R with xts

I would like to calculate rolling yearly differences based on a daily time series in R with a xts object. However, I see currently two issues: The number of trading days per year is not constant. There could be holes in the time series, e.g. one…
p.vitzliputzli
  • 135
  • 1
  • 11
0
votes
2 answers

Using date and seconds from midnight columns to convert a data.frame to an xts object (R)

Suppose I have data that looks like this: DATE TIME Col1 Col2 1 1993-01-04 34538 10.250 10.000 2 1994-01-05 34541 10.250 10.111 3 1997-03-16 34546 10.250 10.222 4 2017-11-10 34561 10.251 10.333 5 2001-08-28 34565 10.251 10.444 6…
D.J. P.
  • 98
  • 8
0
votes
1 answer

apply.weeky function is suddenly returning "'x' must be numeric" only when using "sum" or "colSums"

I've been importing data from a csv, then putting it into a dataframe. I then pad it, convert it to an XTS. After that I use apply.weekly to break it down into weekly data. The code is…
0
votes
2 answers

creating columns of monthly averages in R

I have a dataframe in R where each row corresponds to a household. One column describes a date in 2010 when that household planted crops. The remainder of the dataset contains over 1000 columns describing the temperature on every day between…
bricevk
  • 197
  • 8
0
votes
2 answers

R xlab and ylab in xts plot

Plotting an xts should be really easy, but I can't seem to get the xlab, and ylab to work.. ylab="Price" xlab="Date" plot(x = basket[, 1], lty="dotted", xlab = xlab, ylab = ylab, col = "mediumblue", lwd = 2) title("Cumulative") This will plot…
Anders
  • 73
  • 7
0
votes
1 answer

Converting date and hour into xts R

i have this table of consumptions. I am trying to convert the first two columns into a one xts date format. 1 01.01.2016 00:00:00 26.27724 2 01.01.2016 01:00:00 24.99182 3 01.01.2016 02:00:00 23.53261 4 01.01.2016 03:00:00 …
0
votes
1 answer

Change name in xts loop plots

I have a loop on four xts plots: basket <- cbind(AAPLG, GEG, SPYG, WMTG) tickers <- c("AAPL", "GE", "SPY", "WMT") par(mar = c(3, 3, 3, 3)) par(mfrow=c(2,2)) for (i in 1:4){ print(plot.xts(x = basket[, i], xlab = "Time", ylab = "Cumulative Return", …
Anders
  • 73
  • 7
0
votes
1 answer

R loop xts plots

I am stuck on what is probably a simple problem: Loop on xts objects. I would like to make four different plots for the elements in the basket: basket <- cbind(AAPLG, GEG, SPYG, WMTG) > head(basket) new.close new.close.1 new.close.2…
Anders
  • 73
  • 7
0
votes
1 answer

ACF: How to get x-axis scaled by days instead of seconds (Posix date)

Below is a plot of ACF for 30 days. My problem though is, that the x axis is in seconds. Its an xts object and I guess the problem is, that its class is POSIX as discussed here: R / Time Series: What's the lag unit for autocorrelation function…
Anders
  • 73
  • 7
0
votes
1 answer

xts Object - adding missing dates

I am working with S&P500 stock price data from Yahoo Finance (downloading data through getSymbols function). Over the weekends, the stock price doesn't change therefore the dates are not included. I would like to add in all missing dates (weekends)…
0
votes
1 answer

xts creates an additional day when converting to xts

I have some time series data similar to the following: AAPL.Close MSFT.Close GOOG.Close INTC.Close NVDA.Close 2020-01-06 299.80 159.03 1394.21 59.93 237.060 2020-01-07 298.39 157.58 1393.34 58.93 …
user8959427
  • 2,027
  • 9
  • 20
0
votes
2 answers

Shifting multiple columns down by one row in R

I have number of columns in my dataset and I need to shift columns 18:101 down by one row. So far, I found this command in another thread to be helfpul and below I apply it to my data: data.xts$AR2_Forecast <- transform(data.xts$AR2_Forecast,…