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

R xts does not recognize my POSIXct dates

I have a dataframe (data_frame) with two columns. > head(data_frame) Date Rainfall 1 1992-01-06 14:00:00 0.3 2 1992-01-06 15:00:00 0.2 3 1992-01-06 16:00:00 0.3 4 1992-01-06 18:00:00 0.1 5 1992-01-06 19:00:00 …
0
votes
1 answer

Compute average over 20 second intervals and group by another column

I'm working with a large dataset of different variables collected during the dives of elephant seals. I would like to analyze my data on a fine-scale (20 second intervals). I want to bin my data into 20 second intervals, basically I just want to get…
Shawn68
  • 19
  • 4
0
votes
1 answer

Calculate correlation on a monthly/weekly level

I am having trouble calculating the correlation coefficient between electricity prices of different countries on monthly/ weekly level. The dataset (https://github.com/Argiro1983/prices_df.git) looks like this: prices_df<-structure(list(DATETIME =…
Iro
  • 37
  • 5
0
votes
1 answer

How to predict values into the future using either gam or forecast

I have some fish data that I would like to make predictions for into the future. I would like to predict 'fishcount' based on two variables (airtemp_f and watertemp_f). I, ideally would like to use the R package forecast to predict fishcount 2 or 3…
Salvador
  • 1,229
  • 1
  • 11
  • 19
0
votes
1 answer

Changing datatypes after converting from tibble to xts

I scraped data from online, and it's stored as a tibble with the following data types: tibble [40 x 4] (S3: tbl_df/tbl/data.frame) $ Date : Date[1:40], format: "2021-02-10" "2021-02-09" "2021-02-08" ... $ Net Asset Value :…
John
  • 65
  • 5
0
votes
1 answer

Left join and select the next observation in time in R

Suppose I have two dataframe df <- data.frame(ID=c("Ana", "Lola", "Ana"), Date=c("2020-06-06", "2020-06- 06", "2020-06- 07"), meat=c("fish", "poultry", "poultry"), time_ordered=c("2020-06-06 12:24:39",…
Lola1993
  • 151
  • 6
0
votes
0 answers

How to calculate the stock price volatility in a specific period of time in a xts object

I have a relative large xts object. It contains the daily adjusted closing prices from 2012-2021 for each company in the STOXX 600 Europe. I want to calculate the yearly volatility of the stocks for each year for each company. Here is a link of how…
0
votes
1 answer

How to write a for loop in R to set periodicity as well as start and end date of datasets in list

I'm trying to set the start_date and end_date of datasets in list as well as it's periodicity in R. But I'm not able to write a for loop for selecting the datasets in the list. The code is as follows require(quantmod) require(xts) econ_data <-…
RISHI
  • 1
  • 3
0
votes
1 answer

period.apply function with large endpoints

I have a time series and want to use period.apply() function xts library to estimate the mean for 377 days The reproducible example is as following zoo.data <- zoo(rnorm(5031)+10,as.Date(13514:17744,origin="1970-01-01")) ep <-…
Azam Yahya
  • 646
  • 1
  • 7
  • 10
0
votes
1 answer

Simple Questions on how to get specific elements in a xts object

I have a relative large xts object. It contains the daily adjusted closing prices from 2012-2021 for each company in the STOXX 600 Europe. I want to calculate the yearly volatility of the stocks for each year for each company. So for example I want…
0
votes
1 answer

R cut - labels have look-ahead bias

I just can't get this trivial behaviour to work. I've included a lot of examples to show the problem. I have minute bar data and I'd like to group 15 bars and execute a function on them which will then result in 15-min bar data. The timestamps that…
s5s
  • 11,159
  • 21
  • 74
  • 121
0
votes
2 answers

Turn dummy variables into weights

I have a table of dummy variables where the value is either 1 or NA. I know want to create a uniform weight for these dummies across rows. This is my beginning dataset, it is in xts format: NESN ROG NOVN ZURN ABBN UBSG LONN 1989-12-01 1…
Elias K.
  • 513
  • 1
  • 4
  • 12
0
votes
0 answers

Error in svd: infinite or missing values in x

I am trying to fit and ARIMAX model. fit_ARIMAX = auto.arima( y = df_ARIMAX_train[,"Y"], xreg = df_ARIMAX_train[, c("X1", "X2"], ic = "aic", trace = TRUE, stepwise = FALSE, seasonal = TRUE, approximation = F, parallel =…
Umi
  • 7
  • 3
0
votes
2 answers

Creating dummy from multiple xts objects

I have multiple xts objects which are all indicators if a stock is above or below a certain median value. These list are structured the following way the size variable is S or B the value variable is H or L and the momentum variable is D or U. This…
Elias K.
  • 513
  • 1
  • 4
  • 12
0
votes
0 answers

mutate() command seems not working for objects of different classes

SOLVED I'm working on replication of the code that is used at the Reproducible Finance with R. A link to the webinar is here: https://www.rstudio.com/resources/webinars/reproducible-finance-with-r/ The data for the exercise was downloaded from…
dkolkin
  • 81
  • 10