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

Is there a way to plot 2 or more series with ggplot2 from an xts object?

Is basically the problem described here Plotting an xts object using ggplot2 But I can not adapt it to plot two series, the code is the following: dates <- c("2014-10-01", "2014-11-01", "2014-12-01", "2015-01-01", "2015-02-01") values1 <-…
Jair
  • 15
  • 5
0
votes
1 answer

Using XTS at the start of GARCH Models: Error in xtsAttributes(Returns) : object 'Returns' not found

I start by importing a dataset from Excel. My code is then as follows (BTC1 is what I have called the dataset when I imported it). # Convert column `Date` to date BTC1$Date <- as.POSIXlt(BTC1$Date,format="%Y:%M:%D", origin =…
0
votes
2 answers

How do I retain all the columns while using tq_transmute() function?

I am trying to replicate a trading strategy and backtest in R. However, I am having a slight problem with the tq_transmute() function. Any help would be appreciated. So, I have the following code that I have written until now: #Importing the…
Biv
  • 1
  • 1
0
votes
1 answer

How to find the position of the first non-NA element in a column starting with the last element in an xts object

> vols vol_tr vol_yz vol_cl vol_iv 2021-01-22 0.06260922 0.09798388 0.09861034 NA 2021-01-25 0.09783596 0.10595096 0.10121109 0.1362547 2021-01-26 0.10485836 0.10672985 0.10117991 0.1388527 2021-01-27 0.08284200…
Rod Purkey
  • 5
  • 1
  • 2
0
votes
2 answers

Run analysis only on a intraday time period - zoo

I need to run an analysis from 10AM to 4PM. The original data runs from 9 AM to 5 PM, everyday for one year. How to include only the indicated time period for analysis ? window in zoo does not help for the same. structure(c(0, 7.12149266486255e-05,…
shoonya
  • 292
  • 1
  • 10
0
votes
1 answer

Unify 'datetime' format of data

Due to errors in my database/export, I have an inconsistant timestamp - sometimes with seconds, sometimes without - how can I easily unify it? e.g. read_csv with X1 = col_datetime(format = "%d.%m.%Y %H:%M:%S") is not working properly. My data look…
Herr Student
  • 853
  • 14
  • 26
0
votes
2 answers

convert year and month into date format

I have dates in format 192607 192608 and want to transform them so that they are in the following format and can be used for a xts object 1926-07-01 1926-08-01 I have tried working with as.date and paste() but couldn't make it work. Help is very…
Katharina Böhm
  • 125
  • 1
  • 8
0
votes
0 answers

Adding dates instead of numerical values on x-avis using plot.ts

I am working on a script in R, where I have to plot three estimated models stored in a matrix as a plot against time. I have used the "quantmod"-package to extract the data from Yahoo Finance and hereafter created a vector containing the dates of…
0
votes
1 answer

How to plot a column after deleting a few rows from the data frame?

Language: R Data: from "Yahoo! Finance" I am trying to delete 100 rows of data from a stock price dataset and then I want to plot the "Close" column. I expect to see a straight line inside the graph(for the missing values area). When I am running…
0
votes
1 answer

Create irregular sequence with lubridate in R

I am attempting to create a time series in R using xts(). My dataset details passenger demand every 15 minutes from 06:30 to 22:00 from 2005-03-01 to 2005-03-21. With lubridate, the following code gets me close, but also includes unwanted…
0
votes
1 answer

Replace only the last zero value with the previous value in xts data

I have an XTS data frame of zeros, 1's and -1's and I want to change the only the first zero value after the numbers to the value of this number for example if the column is 0,0,0,1,1,1,**0**,0,0 I want it to be as 0,0,0,1,1,1,**1**,0,0 and if…
0
votes
2 answers

Aggregate data by irregular time periods ("xts" library)

I am trying to follow this stack post over here: How to get sum of values every 8 days by date in data frame in R Does anyone know why this doesn't work? library(xts) set.seed(123) property_damages_in_dollars <- rnorm(731,100,10) …
stats_noob
  • 5,401
  • 4
  • 27
  • 83
0
votes
1 answer

How to find a day with maximum outliers

I have timeseries with several days data. I need to find a day with maximum number of outliers and plot only this day data. Here how I do it: #generate sample data Sys.setlocale("LC_ALL","English") Values <- sample(0:100,24241, replace =…
Maxim
  • 301
  • 1
  • 9
0
votes
1 answer

Time Series object error when ordering by date

I found responses to this very question answered on SO but I still can't get my specific case to work. I am trying to create a time-series object for use in a time series model. I've converted the date values in my dataframe to "Date" column…
bbal20
  • 113
  • 4
  • 11
0
votes
1 answer

Multiplying two xts objects with each other

I have a xts list that looks like this (my list is called prices): head(prices[[1]]) X ID Name Price Shares.Outstanding 1980-03-31 "170481" "55160" "Donec Non Ltd" "5,72762874283858" "973,74375" …
Katharina Böhm
  • 125
  • 1
  • 8