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

How does zoo or xts to deal with two-dimensional tables?

I have a two-dimensional table. and i want to know How to import Rstudio by read.zoo? And generate a line graph.thanks everybody!
glig
  • 33
  • 6
0
votes
1 answer

Reset cumprod when NA is encountered

I have an xts object with monthly returns of stocks. I want to calculate a rolling cumulative return for the stocks. Some of the stocks have NAs in the data. I want the cumulative return to reset to 1, each time an NA is encountered. Here is some…
Mr.Rlover
  • 2,523
  • 3
  • 14
  • 32
0
votes
1 answer

How to sort xts-matrix by column if the headers are numbers

I have two xts-matrices (A and B) were both contain headers in the form of "value1.value2". This label combination is saved for both matrices as characters to avoid R to attach the prefix "X" to the numbers. A and B are already labeled with their…
StableSong
  • 79
  • 11
0
votes
1 answer

Formating xts date & time X2020.01.06.06.00.00

I have an xts table all.transactions showing: structure(list(Quantity = c(0, 162000, 149000, -149000)), row.names = c("X2020.01.06.06.00.00", "X2020.01.10.15.00.00", "X2020.02.03.15.00.00", "X2020.02.03.15.00.00.1" ), class = "data.frame") I…
Rene Chan
  • 864
  • 1
  • 11
  • 25
0
votes
1 answer

How to combine a column from a xts zoo object to a table object?

I'm having trouble to join two dfs and I believe it occours due to having two diferente objects. Here is my first df: head(df1) ativo dia BBAS3.SA ITSA4.SA PETR4.SA 2000-03-31 -0.16925030 0.04819535 0.02141427 …
Washington Muniz
  • 100
  • 1
  • 1
  • 7
0
votes
1 answer

R setting column name on do.call(rbind)

In summary, I am looking to add a cumulative volume column to an XTS object. However, upon calling do.call(rbind... I find the original XTS gets overwritten. # Reproducible example data foo <- rnorm(5) bar <- seq(as.Date("1970-01-01"), length = 5,…
Little Code
  • 1,315
  • 2
  • 16
  • 37
0
votes
1 answer

How do I remove the time zone from a POSIXct timestamp for conversion to XTS?

For some reason when I convert my time series data from a data frame to an xts object, the timezone is included in the index. I suspect this is what the issue is when I try to run time series modelling on the object because I keep getting errors. …
jem888
  • 1
  • 2
0
votes
1 answer

How to create month-end date series using complete function?

Here is my toy dataset: df <- tibble::tribble( ~date, ~value, "2007-01-31", 25, "2007-05-31", 31, "2007-12-31", 26 ) I am creating month-end date series using the following code. df %>% mutate(date =…
Geet
  • 2,515
  • 2
  • 19
  • 42
0
votes
2 answers

R - call xts via character

Assume we have a list of characters as basis for a function, which has a xts object with the same name as result: library(zoo) library(xts) library(quantmod) l<-list("AAPL","NKE") for(i in 1:length(l)){ getSymbols(l[[i]], src = "yahoo") …
Joe
  • 15
  • 6
0
votes
2 answers

R: xts conversion problem (Add x's at the index row)

This is my setup: I have an excel-file with hourly electricity prices. I want to index them by the hourly interval, file here: Data. I load the data the usual way. library(readxl) library(tidyverse) rm(list = ls()) DK1 <- read_excel("DK1.xlsx")…
NotPzl
  • 21
  • 4
0
votes
1 answer

converting date (month) only to XTS class in R

I have a csv file which I read in R library(xts) mydata <- read.csv("abc.csv") ==> it becomes a dataframe Months Round Premium December 2 1000 December 1 2000 November 2 1500 November 1 1200 ... January 2 …
james lim
  • 39
  • 4
0
votes
1 answer

Spotvol calculation on xts object keeps producing POSIX and Error in set errors

I am trying to calculate the daily realised / historical volatility for a large dataset of equities by using the spotvol function from the highfrequency package. For some reason I keep getting POSIX (timestamp) errors and I have tried a number of…
jem888
  • 1
  • 2
0
votes
1 answer

min and max over time range on each day of xts

I have an xts object with intraday OHLC price data over several years. I'd like to be able to write a function that calculates the min and max value between 04:00:00 and 05:00:00 every day and include that as a column in the xts object. Im not…
0
votes
1 answer

R: creating xts object changes the time format

> str(s) POSIXct[1:6630], format: "2011-02-14 09:31:00" "2011-02-14 09:32:00" "2011-02-14 09:33:00" "2011-02-14 09:34:00" ... > head(s) [1] "2011-02-14 09:31:00 EST" "2011-02-14 09:32:00 EST" "2011-02-14 09:33:00 EST" "2011-02-14 09:34:00 EST" [5]…
codingknob
  • 11,108
  • 25
  • 89
  • 126
0
votes
1 answer

How to apply function over a list by taking list of list elements as function argument?

Reproduce-able data set- set.seed(55) data <- rnorm(8) dates <- as.POSIXct("2019-03-18 10:30:00", tz = "CET") + 0:7*60 dataset <- xts(x = data, order.by = dates) colnames(dataset) <- "R" dataset$Timestep <- 1:8 dataset$Label <-…
Rel_Ai
  • 581
  • 2
  • 11
1 2 3
99
100