Obtaining 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 ArticleHow do I debug for different inputs in R when dput() results are seemingly...
I've been wrangling data in Python to comply with the documentation for the "BGVAR" package in R.It states that for the bgvar class I need to input Data as a list of dataframes where each item is named...
View ArticleXTS in R studio
I'm reading a binary output file of a program using a R package. When I executed the below line of code I see a data structure as shown in the snapshot under the 'Environment' tab of R Studio.output...
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 ArticleXTS: split FX intraday bar data by trading days
I want to apply a function to 20 trading days worth of hourly FX data (as one example amongst many).I started off with rollapply(data,width=20*24,FUN=FUN,by=24). That seemed to be working well, I could...
View ArticleHow to create a variable based on a given growth rate using xts?
I want to create a variable based on a given growth rate, which is in another variable, starting from a base of 1. Below is an example. I tried two methods, either applying growth rate to lagged value...
View Articlevectorization in xts is there a simple solution
set.seed(2)library(xts)x <- sample(1:5,10,replace = T)x.xts <- xts(x, order.by = seq(as.POSIXct(Sys.time()), length = 10, by = "min"))I have xts object x.xts and i want apply to him vectorized...
View ArticleOpenSSL3.1 C example of AES-XTS using EVP interfaces Unable to segment data...
For AES-XTS encryption, I want to perform segmented input calculations on the data, but it has a problem.#include <openssl/evp.h>#include <openssl/rand.h>#include <stdio.h>#include...
View ArticleHow to transform/simplify a data.frame with timeseries in columns to an...
How do I go from image #1 to #2 in R ?I would expect this transformation to be so common in timeseries analysis that xts::, zoo:: or data.table:: would have a pre-built routine to make the series...
View ArticleAuto.arima different results for .zoo and .xts object? [closed]
I have time series of Covid-19 death cases which is only weekdays without weekend. I created it in R as .zoo object. But since some packages work better with time series I created it as .xts object as...
View ArticleAuto.arima from forecas-Different results for Zoo object and.xts object?
I have time series of Covid-19 death cases which is only weekdays without weekend. I created it in R as .zoo object. But since some packages work better with time series I created it as .xts object as...
View ArticleFiltering a xts object from one year to the next
If I have a 10-year daily xts time series, starting on 1985-01-01 and ending on 1994-12-31, how can I calculate the sum of values for the interval starting on Nov 1 and ending on Mar 31 of the next...
View ArticleAdd a subtitle to plot.xts
Is there a way to add a subtitle like in base plot to plot.xts?plot(xts(rnorm(100), order.by = as.Date(1:100)), sub = "Subtitle")plot(rnorm(100), sub = "Subtitle", type = "l")
View Articlewhy don't the names change to those that were specified in the date frame?
I wrote a simple function that combines all indicators from the TTR package, but not all indicators have names that have changed as I specified in the dataframe.for example, TTR::chaikinVolatility...
View ArticleHow to use gstar package of R for spatio-tempral analysis?
I want to perform a spatio-temporal analysis by highlighting spatial as well as temporal dependencies of the data (I have a 'weight matrix' highlighting spatial dependencies of the counties) on the...
View Articlehow to build multiple sliding windows from xts object using rollapply function
I have a matrix with two columns where each column is a variable. I'm building two sliding windows of size 3data <- matrix(1:20,ncol = 2, dimnames = list(NULL, c("var1","var2")))> data var1 var2...
View Articlelist of xts objects back to list after merge
I have a list of xts objectsset.seed(1)library(xts)tm <- Sys.time()+1:10f <- function(){ m <- matrix(1:40,ncol = 4, dimnames = list(NULL, paste0("x",1:4))) xts(m ,tm)[-sample(10,sample(9,1))]}...
View Articleprinting an xts object
I am trying to create an xts object of this S&P500 sample. This is the code I am using:sp500 <- read.csv2("SP500.csv", stringsAsFactors = F, header = T, sep = ",", na.strings = ".")sp500$DATE...
View ArticlePlot multiple series on a dygraph
I'm trying to plot multiple series on a dygraph line chart.The df is of this structure:structure(list(Date = structure(c(4216, 4216, 4217, 4217, 4218, 4218, 4219, 4219, 4220, 4220, 4221, 4221, 4222,...
View ArticleIs it possible to get the specific index of occurence when working with...
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 Article