Quantcast
Browsing all 57 articles
Browse latest View live

How can I interpolate my time series to have the same size (for clustering...

I have a list (df_list) of 40 time series (class "xts" "zoo") with different lengths and would like to interpolate them against the time series with the longest length to obtain time series of the same...

View Article


How can I split an xts object into chunks of similar size, but continuously...

I did this but split the series into random chunks: chunks <- split(GC, f = 1:3)I need continuous chunks, taking into account the date that is in the index.

View Article


Image may be NSFW.
Clik here to view.

can't draw "chart_Series" graph in loop "quantmod package"

I just installed the latest version of R and installed the latest version of Rstudio and ran into an interesting problem.It turned out that I can draw one...

View Article

Take every Xth value of an xts object

I've got an xts object that contains data in a temporal resolution of seconds. For instance:times <- seq.POSIXt(from=as.POSIXct("2023-04-01 00:00:00"), to=as.POSIXct("2023-04-04 00:01:00"), by =...

View Article

How to divide the columns in a time series by their first value in R?

I have the code below working. But there must be a better way.file <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1127/datasets/tmp_file.csv"x <- read.csv(file = file)ts <-...

View Article


Image may be NSFW.
Clik here to view.

How to split xts OHLC data by the specified number of candles

I have candle datalen <- 10000times <- seq(as.POSIXct("2016-01-01 00:00:00"), length = len, by = "sec")prices <- cumsum(rnorm(len))+1000library(xts)xp <- xts(x = prices,order.by = times)xp...

View Article

Cannot Create xts Object from Data.Frame that has Properly Formatted Date Index

frame that should be properly formatting with a date index that's properly formatted to be an .xts. However, I cannot complete the conversion to an xts object and receive the following error:Error in...

View Article

display format of xts when time is 00:00

How can I change the format of the return value of last if the time of that time step is 00:00?Here is an exampleI have two xts objects containing hourly observations with different end times that I...

View Article


Converting a data frame to xts

I'm trying to convert a data frame to xts object using the as.xts()-method. Here is my input dataframe q:q t x 1 2006-01-01 00:00:00 1 2 2006-01-01 01:00:00 2 3 2006-01-01 02:00:00 3str(q)'data.frame':...

View Article


Matching R time series class between input and output

I have an R function that analyzes regular time series, originally written by assuming the data were just a vector, say of length N. It outputs a list of vectors that are either of length N or length...

View Article

Period apply after filtering missing data

I have a large xts of 10 minute data that I am trying to average hourly. The data also has some missing data within it. I want to average all of the hours that have >50% data completeness but...

View Article

How to access xts column by name in a function in R?

How would I access an xts column by name in a function? The code below returns NULL.#m(list=ls())#dev.off(dev.list()["RStudioGD"])getSymbols("^GSPC",src="yahoo",from="2015-01-01",to =...

View Article

Basic lag in R vector/dataframe

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)ds <-...

View Article


how to shift an xts time series to the left in r?

I am trying to shift one column of an xts time series to the left in R (please see the code below). The lag shifts nicely to the right, but I want it to line up with the rolling mean. Using a negative...

View Article

error in xts - "'order.by' cannot contain 'NA', 'NaN', or 'Inf'"

I am trying to convert a csv data.frame into an xts and keep getting the following error:the file is a csv daily stock data downloaded from Yahoo Finance for "AAPL"Here is what I did so...

View Article


Aggregate daily level data to weekly level in R

I have a huge dataset similar to the following reproducible sample data. Interval value1 2012-06-10 5522 2012-06-11 48503 2012-06-12 46424 2012-06-13 41325 2012-06-14 41906 2012-06-15 41867 2012-06-16...

View Article

Calculate Return with R

I'm a new to R. I have an Excel file called "bitcoin" which contains two columns: "date" and "BTC.Close". I've imported the data into R and transformed it into an xts object. However, I'm encountering...

View Article


Data table output looks very different than xts output

I'm having trouble viewing a data table in a tabular format. If I use the PCRA package and export a dataset as an xts object (see the minimal example below), the xts object resembles a...

View Article

How to aggregate a dataframe by week?

Consider the following examplelibrary(tidyverse)library(lubridate)time <- seq(from =ymd("2014-02-24"),to= ymd("2014-03-20"), by="days")set.seed(123)values <- sample(seq(from = 20, to = 50, by =...

View Article

How to round trip (to and from a .csv file) with an xts object?

Trying to do a round trip (write/read) with an xts object. read.zoo() returns a data frame! Converting this to an xts fails.How do I make it an xts object?library(quantmod)from <- "2016-01-01" ##...

View Article
Browsing all 57 articles
Browse latest View live