xts Questions

5

Solved

I can get today's date: Sys.Date( ) But how do I get last Friday's date? I tried: library(xts) date1 <- Sys.Date( ) to.weekly(date1 ) But this gives an error.
Replicate asked 10/3, 2015 at 18:42

2

Solved

I've got an xts df of the following format: structure(c("May 2022", "Jun 2022", "Jul 2022", "Aug 2022", "Sep 2022", "Oct 2022", "No...
Recusant asked 20/12, 2022 at 15:55

3

I have daily prices series over a wide range of products; I want to convert to a new dataframe with weekly or monthly data. I first used xts in order to apply the to.weekly function...which works ...
Indeterminism asked 8/5, 2013 at 13:46

4

Solved

As of tibble package version 2.0.1 what is the best way to convert an xts object into a tibble? Consider the following example: library(tibble) library(xts) myxts <- xts(matrix(1:4, 2, 2), or...
Erma asked 26/2, 2019 at 15:22

2

More than a solution I'd like to understand the reason why something which should be quite easy, it's actually not. [I am borrowing part of the code from a different post which touched on the issu...
Systemize asked 18/5, 2017 at 7:36

13

Solved

Will most likely expose that I am new to R, but in SPSS, running lags is very easy. Obviously this is user error, but what I am missing? x <- sample(c(1:9), 10, replace = T) y <- lag(x, 1) d...
Rudolfrudolfo asked 24/8, 2010 at 17:4

3

I am trying to convert a irregular time series of a data table into a regular time series. My data looks like this library(data.table) dtRes <- data.table(time = c(0.1, 0.8, 1, 2.3, 2.4, 4.8, 4...
Echoism asked 2/6, 2020 at 14:11

3

I have an irregular time series of events (posts) using xts, and I want to calculate the number of events that occur over a rolling weekly window (or biweekly, or 3 day, etc). The data looks like t...
Arbitrary asked 11/5, 2012 at 18:7

2

Solved

I would like to build an animated map with a time cursor in R. I have time series (xts) that I would like to represent on map. library(xts) library(leaflet) date<-seq(as.POSIXct("2015-01-01"),...
Mezzorilievo asked 21/5, 2015 at 10:16

5

Solved

I've got a data frame with the following data: >PRICE DATE CLOSE 1 20070103 54.700 2 20070104 54.770 3 20070105 55.120 4 20070108 54.870 5 20070109 54.860 6 20070110 54.270 7 20070111 54.770 8...
Wincer asked 4/1, 2012 at 19:4

4

Solved

I am pretty sure this is quite simple, but seem to have got stuck...I have two xts vectors that have been merged together, which contain numeric values and NAs. I would like to get the rowSums for...
Polytechnic asked 12/8, 2013 at 14:34

2

Solved

I have a timeseries of monthly data with lots of missing datapoints, set to NA. I want to simply subtract the annual cycle from the data, ignoring the missing entries. It seems that the decompose f...
Berky asked 13/9, 2018 at 10:32

5

Solved

Is there a way we can fill NAs in a zoo or xts object with limited number of NAs forward. In other words like fill NAs up to 3 consecutive NAs, and then keep the NAs from the 4th value on until a v...
Vandalize asked 19/9, 2014 at 18:28

3

Solved

I often run into the same issue of how to handle NA values when modelling quantitative trading models. The example below is about a stock with EOD data since 1997-01-01 stored in a xts object with ...
Spall asked 15/10, 2012 at 20:37

2

Solved

I am having trouble deleting duplicated rows in an xts object. I have a R script that will download tick financial data of a currency and convert it to an xts object of OHLC format. The script also...
Tombouctou asked 14/1, 2012 at 20:48

5

I have a time series data with 1 minute increments. I have written a code but with the large amount of data I have (over 1M rows), looping through each line is taking way too long. The data looks s...
Diestock asked 24/12, 2018 at 17:9

2

Solved

I want to extract the numerical values of a xts object. Let's look at an example data <- new.env() starting.date <- as.Date("2006-01-01") nlookback <- 20 getSymbols("UBS", env = data, src...
Cleavable asked 5/4, 2014 at 13:23

6

Solved

I have an XTS timeseries in R of the following format and am trying to do some processing, subsetting and re-arranging before exporting as a CSV for work in another program. head(master_1) S_1 20...
Rouen asked 2/8, 2010 at 10:24

1

Solved

I have two datasets. Both are xts objects. > dput(head(all_data[,2:3])) structure(c(0.00108166576527857, 0.00324149108589955, 0, 0, 0.00484652665589658, 0.00267952840300101, 0.0060698027314...
Cheese asked 26/7, 2018 at 20:56

2

I have an issue finding the most efficient way to calculate a rolling linear regression over a xts object with multiple columns. I have searched and read several previously questions here on stacko...
Foliolate asked 8/8, 2012 at 21:2

4

Solved

I have a dataset containing 10 events occuring at a certain time on a given day, with corresponding value for each event: d1 <- data.frame(date = as.POSIXct(c("21/05/2010 19:59:37", "21/05/2010...
Linzy asked 21/12, 2014 at 23:41

4

Solved

> library(PerformanceAnalytics) > data(managers) > class(managers) [1] "xts" "zoo" > head(managers) HAM1 HAM2 HAM3 HAM4 HAM5 HAM6 EDHEC LS EQ SP500 TR US 10Y TR US 3m TR 1996-01-31 0.0...
Hyperventilation asked 23/12, 2013 at 17:56

2

Solved

Applying the split function to a xts object by weeks groups rows into weekly chunks. The default days in the group are Monday to Sunday. What do I do if I want the days in the group to be from Sund...
Hazard asked 1/4, 2018 at 23:7

2

Solved

I have an xts of 1033 daily returns points for 5 currency pairs on which I want to run a rolling window regression, but rollapply is not working for my defined function which uses lm(). Here is my ...
Bethanie asked 19/2, 2012 at 16:48

1

Hi i'm converting some 1 min data to 5 min data, and i'm finding it does 4 mins for the first increment, then goes on to do 5 min increments after that. I've tried messing around with all the "in...
Fond asked 15/8, 2015 at 0:45

© 2022 - 2024 — McMap. All rights reserved.