R:将每日时间剧本数据转换为每月
我正在尝试使用SystemICR软件包找到Deltacovar,但是我在每日时间序列数据中以XTS形式正确阅读我的CSV文件并将其转换为每月数据。 我收到以下提到的错误。如何解决此错误或/并正确阅读我的数据?非常感谢您
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)
XTS中的错误(v_returns,order.by = v_date): nrow(x)必须匹配长度(order.by)
date | btc | et | ltc | xmr |
---|---|---|---|---|
9/1/2015 | 227.96 | 1.36 | 1.36 2.82 | 0.45 |
9/2/2015 | 229.5 | 1.31 | 2.31 2.82 | 0.45 |
9/3/2015 | 227.11 | 1.23 | 227.11 1.23 2.64 | 0.45 |
9/4/2315 231.15 | 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.56 | 0.5 |
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 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
通常在R和XTS中查看
apply.monthly()
函数。apply.monthly:在日历期间应用功能
Generally check out the
apply.monthly()
function in R and xts.apply.monthly: Apply Function over Calendar Periods