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

Keep Dates when aggregating xts object

I have an xts object where I want to aggregate the data--while keeping the dates. wLn = apply(dLn, 2, to.weekly) > head(wLn) AAPL GSPC VIX [1,] -0.05602066 -0.0252409007 0.01903172 [2,] -0.03609222 -0.0111470571 …
BorgmanC
  • 11
  • 2
1
vote
1 answer

Function to count consecutive non-zero values

With a dataset that looks like this: Index x y 2012-07-24 07:00:00 0.1 0 2012-07-24 07:15:00 0.2 1 2012-07-24 07:30:00 0.3 0 2012-07-24 07:45:00 0.2 0 2012-07-24 08:00:00 0.3 1 2012-07-24 08:15:00…
1
vote
1 answer

R: merge.xts and specific fill function

After merging two unequal time series I want to fill the blanks with a custom function. Lets say my Series1 is daily data and Series2 is monthly data. So now Series1 has for example 30 data points for one month and Series2 only one. If I make a left…
MichiZH
  • 5,587
  • 12
  • 41
  • 81
1
vote
1 answer

Reading in my first xts time series and getting duplicated rows

I am following what I read in this previous answer to create my first xts time series. I am getting duplicated rows in the output, but only for some cases. (The data are at 5 min increments, but there are gaps which are not on the regular 5 minute…
Aditi
  • 13
  • 4
1
vote
0 answers

Shiny: Trying to remove a column in a reactive xts element removes whole object instead

This code is supposed to prepare a subset of data selected basing on user input for plotting usinng dygraph. selectedData <- reactive({ omdata<-mdata[ mdata$Col1 %in% input$col1,]; tomdata<-omdata[omdata$Col2 %in% input$col2,]; …
Krzysiek Setlak
  • 311
  • 1
  • 4
  • 16
1
vote
1 answer

Working with intraday dataset

I have been trying to convert my data so I can get a xts data frame "data" with a time index and two colums Price and Volume. But so far I have had no luck with the code. The data example can be found here.…
Wolfgang
  • 13
  • 2
1
vote
1 answer

quantmod chart_Series plotting a series with NA values

I have a xts series "a" containing the 15minute OHLC and volume of SPY on 2015-09-10 between 9:30AM to 13:00PM, values are NA between 13:00PM to 4PM. I want to plot the whole series with volume bars below the…
Jim Green
  • 261
  • 4
  • 10
1
vote
0 answers

Receiving Error in UseMethod("as.xts") - Can't explain why

I have been running the following series of commands on sets of .csv files that I am loading into my workspace. Everything was working well, until I tried a new data set. I keep receiving the error when I try and display the data in my Shiny…
Gary
  • 2,137
  • 3
  • 23
  • 41
1
vote
1 answer

sfLapply & apply.rolling on a xts object - Resulting Error: subscript out of bounds

My goal is to map daily return of 5 stocks (a xts object) to a rolling standard deviation of a look back period of 90 days (calculating the SD of the return of the last 90 days) with the same data structure and with fast speed. The approach by using…
Anthony Lei
  • 241
  • 1
  • 9
1
vote
1 answer

Rbind on multiple files in directory is duplicating the entries of first file

The program browse through all the files in a folder, process them and rbind them in a single file : files=list.files(path="path", recursive=T, pattern='.xlsx') for(i in 1:length(files)) { #some process goes which generates qs_30 for each file as…
gaurav kumar
  • 859
  • 2
  • 10
  • 24
1
vote
2 answers

R xts Time series, subset by last workday of the week

I have daily closing price in a xts object. What I am trying to do is get the last closing price of the week. Most of the time this will be Friday but sometimes this might be Thursday or even more rare Wednesday. I been trying to subset this with…
Aaron Soderstrom
  • 599
  • 1
  • 6
  • 12
1
vote
2 answers

Converting Multiple xts objects to multiple data.frames in r

I am trying to convert multiple xts objects in the Global environment to be multiple data.frames of the same name. I am trying to create a array of data.frames that can be feed into a program. My code creates the xts objects OK but I would have to…
Dan
  • 11
  • 1
1
vote
1 answer

Use periodReturn with Quandl data

I downloaded a time series from Quandl, using the following command: library(Quandl) Quandl.auth("YOURSKEY") mydata <- Quandl("TFGRAIN/SOYBEANS", authcode="YOURSKEY") Now, I would like to use some functions from the quantmod package. However, I get…
unmark1
  • 322
  • 3
  • 13
1
vote
1 answer

'origin' must be supplied&unambiguous format

I am a beginner in R. I have the following problem - I want to load a CSV file into R and then convert it into a XTS object. However, after the operation I get an error. First, a small snippet of the…
wku
  • 25
  • 3
1
vote
1 answer

xts package, to.weekly(): How to keep initial column names

I have some data which I want to change to a weekly scale with the xts package, everything works fine except that the column names change in an undesirable way. As you can see... > head(x) Open High Low Close Volume (BTC) Volume…
uncool
  • 2,613
  • 7
  • 26
  • 55