Aggregate xts coredata in case of duplicate indices
Assuming I have the following xts object with duplicated time information:library(xts)x <- xts(1:5, c("2024-04-19", "2024-04-19", "2024-04-20", "2024-04-21", "2024-04-21") |> as.Date())x#>...
View ArticleHow Do You Execute If-Then Logic On All The Columns Of An xts object in R
I have an xts object with multiple columns in R and I want to convert all the numbers larger than, say, 0.05 to NA (or -99 or something like that).To get some data to execute on please do the...
View Articledecomposition hourly timeseries
I have the following time series data example: structure(list(cycle_rounded = structure(c(1604534400, 1604538000, 1604541600, 1604545200, 1604548800, 1604552400, 1604556000, 1604559600, 1604563200,...
View Articleas.Date in R completely changes the years
I have a time-series dataset in csv format. The monthly data is from 4/1/1953 to 6/1/2017. I want to convert this into an xts object in R. I used the following codes to import the dataset and then...
View ArticleHow to handle 'Series contains non-leading NAs' in TTR library with xts objects?
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 four...
View ArticleDelimit precipitation events from xts objects using `split.zoo`
I'd like to split an xts object of precipitation depths into chunks in order to be able to delimit individual events for subsequent analysis from a continuous record of observations.Let's assume I'm...
View ArticleWrite ZOO (XTS) object into CSV file by separating index column into two columns
I have 2-column (index and value) ZOO object, where index contains date and time values:2010-02-18 13:11:00 48.090 2010-02-18 13:12:00 48.110 2010-02-18 13:13:00 48.100I want to save this ZOO object...
View Articlejunit.framework.AssertionFailedError: Test is stuck, see ANR stack trace for...
I'm running Test cases but facing the below error.junit.framework.AssertionFailedError: Test is stuck, see ANR stacktrace for more info. You may need to create /data/anr firstThe error occurred in the...
View ArticleControl the minimal number of required values when aggregating xts objects
When working with e.g. daily air temperature data, I'd like to have better control of how many observations are allowed to be missing in order to not calculate the monthly average (or whatever...
View Articlemultiple columns in a sliding window, runner package, xts format
I'm trying to do something similar to w1, which contains colums in a sliding window of size kset.seed(1)library(xts)tm <- Sys.time()+1:5000x <- rnorm(5000) |> cumsum() |> round(1) |>...
View ArticleDygraph multiple plots - turn them on and off with R and dySeries options
Good afternoon everyone,I am discovering dyGraph for R and it is an amazing tool.I need to plot only two variables ("Lifetime.Engaged.Users"& "Lifetime.Post.Total.Reach") of my 32 variables xts...
View Articlehow sort in reverse order xts object
I'm trying to do a regular reverse sort, but I don't understand how to do it with an xts object. I want the last date to be in the first line and not the last.I tried several ways but it doesn't...
View ArticleIs indexAt="lastof" no longer valid for xts::to.weekly?
simple reproducible example:set.seed(1234)len <- 1000fake <- zoo::zoo(rnorm(len, mean = 0.001, sd = 0.0005), order.by = seq.Date(from = as.Date("2000-01-01", tz = "UTC"), length.out = len, by =...
View ArticleForecasting time series data
I've done some research and I am stuck in finding the solution. I have a time series data, very basic data frame, let's call it x:Date Used11/1/2011 58711/2/2011 57811/3/2011 60011/4/2011 59911/5/2011...
View ArticleObtaining last Friday's date
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.
View ArticleGet the specific index of occurence when working with period.apply
Assuming I worked with meteorological observations and wanted to know not only the daily maximum value but also the relevant timestamp, describing when this value was observed, is it possible to...
View ArticlePlotting an xts object using ggplot2
I'm wanting to plot an xts object using ggplot2 but getting an error. Here is what I'm doing: dates <- c("2014-10-01", "2014-11-01", "2014-12-01", "2015-01-01", "2015-02-01")value <-...
View Article