R: Converting daily timeseries data to monthly

66 views Asked by At

I am trying to find the deltacovar using the systemicR package but I am having trouble reading my csv file properly in xts form for my daily time series data and converting them into monthly data. I am getting the below mentioned error. How do I fix this error or/and read my data properly? Thank you very much in advance

library(SystemicR)
library(ggplot2)
library(xts)
library(zoo)
Dataset1 <- read.csv('C:/Users/sha03/Desktop/R/intro/data/CC_data_v2.csv',sep = ";"))
v_returns <- numeric(10)
v_returns <- rnorm(10, 0, 0.01)
v_date <- seq(from = as.Date("2015-09-01"), to = as.Date("2021-11-30"), by = "month")
xts_returns <- xts(v_returns, order.by = v_date)

Error in xts(v_returns, order.by = v_date) : NROW(x) must match length(order.by)

date BTC ETC LTC XMR
9/1/2015 227.96 1.36 2.82 0.45
9/2/2015 229.5 1.31 2.82 0.45
9/3/2015 227.11 1.23 2.64 0.45
9/4/2015 231.18 1.23 2.72 0.47
9/5/2015 235.9 1.36 2.94 0.48
9/6/2015 240.81 1.34 3.08 0.5
9/7/2015 244.17 1.28 3.06 0.5
1

There are 1 answers

0
Herr Student On

Generally check out the apply.monthly() function in R and xts. apply.monthly: Apply Function over Calendar Periods