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

Plot 2 xts object with 2 y-axis different scales

I am having problems while plotting 2 different variables in the same chart. I want to plot the COT Balance and the Price variables of USD/BRL(data is an xts object). tail(COT_USD_BRL) Long.Positions Short.Positions Change.Long…
0
votes
1 answer

Creating a dataframe by extracting information from a xts object

Here is a reproducible example- data <- rnorm(6) dates1 <- as.POSIXct("2019-03-18 10:30:00", tz = "CET") + 0:2*60 dates2 <- as.POSIXct("2019-03-19 08:30:00", tz = "CET") + 0:2*60 dates <- append(dates1, dates2) R <- xts(x = data, order.by =…
Rel_Ai
  • 581
  • 2
  • 11
0
votes
0 answers

Coerce an XTS object to TS for stock daily returns

i'm scratching my head a lot of hours for this problem. I've a xts object with stock return, but i need to coerce this object to ts . Below there is an example. date_vec <- as.Date(c("2010-01-05", "2010-01-06","2010-01-07", …
0
votes
1 answer

Replacing only NA values in xts object column wise using specific formula

I want to replace NA values in my xts object with formula Beta * Exposure * Index return. My xts object is suppose Position_SimPnl created below: library(xts) df1 <- data.frame(Google = c(NA, NA, NA, NA, 500, 600, 700, 800), …
ss003
  • 3
  • 5
0
votes
0 answers

Plotting XTS objects with plot() function and/or ggplot() function

I am trying to plot multiple different xts objects in separate graphs as well as in a single graph. I have found that I cannot use ggplot2 because with all of my xts objects, the date column is in column 0 and I don't know how to name column 0.…
ERV
  • 5
  • 2
0
votes
2 answers

How to use data from two XTS to create a new XTS?

Suppose I have the following two XTS... a <- c(1,2,3,4) b <- c(2,4,6,8) x <- xts(cbind(a,b),order.by = as.Date(c("2015-01-02","2015-01-05","2015-01-06","2015-01-07"))) x and c <- c("a","b","b","a","a","b") d <- c(10,20,10,30,20,40) y <-…
Pasha S
  • 79
  • 6
0
votes
1 answer

How do I merge two XTS by date and value in R?

So I want to merge two XTS based on date and value. Suppose one of them is like this. a <- c(1,2,3,4) b <- c(2,4,6,8) c <- c(3,6,9,12) x <- xts(cbind(a,b,c),order.by=as.Date(c("2015-01-02","2015-01-05","2015-01-06","2015-01-07"))) x So we get…
Pasha S
  • 79
  • 6
0
votes
1 answer

Xts format of data.frame

I have a dataframe with 2 columns in it. The first column contains POSIXct data, and the second contains some sample value integers. I cannot for the life of me figure out how to convert this dataframe to xts. My data: structure(list(SampleDateTime…
0
votes
1 answer

Aggregate on a xts object by matching column names with grouping variables present in another dataframe in R

I have a time series object suppose : library(xts) exposure <- xts(Google = c(100, 200,300,400,500,600,700,800), Apple = c(10, 20,30,40,50,60,70,80), Audi = c(1,2,3,4,5,6,7,8), BMW = c(1000,…
ss003
  • 3
  • 5
0
votes
1 answer

autoplot using wrong time for xts

I used autoplot() function to plot a time series data including the arima forecast from the forecast() function. The x-axis of the plot is wrong. The data is used xts from 2000/01/01 to 2019/09/01, but obviously the result is not using this…
0
votes
2 answers

dateFormat in as.xts function

I want to convert the dataset "co2" that comes in R to a CSV. My code is the following: require(xts) require(zoo) co2_xts <- as.xts(co2) write.zoo(co2_xts, file="demo.csv",sep=",") This works fine. But the time index shows as, for example, "ene.…
davidaap
  • 1,569
  • 1
  • 18
  • 43
0
votes
2 answers

How to replace every six row in a data set with its lag starting from 7th row

I want to replace every sixth row in xts from a data set with its lag. This process should start from the 7th row, which means that the 7th row will be replaced by the 6th row, the 13th row will be replaced by 12th row, and so on.
jeetkamal
  • 399
  • 2
  • 12
0
votes
1 answer

Mean and SD of whole column with xts

might be a simple question but I am having trouble trying to get the mean and standard deviation over a whole period 2007-2019 from a xts object and not just the yearly info. Is there a way to do this all at once? apply.yearly(zxl$logs, mean) …
Orfevre
  • 111
  • 8
0
votes
0 answers

How do I fix my XTS (timeseries) to correlate to my CSV file?

So I have a "calendar" that reminds me of certain things that need to be done on an excel spreadsheet, sent through with email (MailR). There are two columns, one is the date and the other is the task. The format of the spreadsheet looks like…
datacookies
  • 13
  • 1
  • 8
0
votes
1 answer

Split, lapply, rbind paradigm. lapply returning lists of numerics instead of date index

I'm practicing time-series analysis on the Red Sox seasons dataset. I need to split the dataset year by year and do some calculation, so I'm pretty sure I need to use the split, lapply, rbind paradigm. I'm feeding an xts binary (win/loss) column to…
Omar Omeiri
  • 1,506
  • 1
  • 17
  • 33
1 2 3
99
100