r - xy.coords(x, y) 中的错误:“x”和“y”长度不同的图表。PerformanceSummary R XTS
问题描述
运行以下代码:
charts.PerformanceSummary( xts(c(.05,.01,-0.1),as.POSIXct(c('2018-02-28','2018-03-29','2018-04-24'))))
我得到错误:
Error in xy.coords(x, y) : 'x' and 'y' lengths differ
以下是 sessionInfo() 的结果:
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] compiler parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] googlesheets_0.2.2 PerformanceAnalytics_1.5.2 doParallel_1.0.11 iterators_1.0.9 foreach_1.4.4
[6] TTR_0.23-3 xts_0.10-2 zoo_1.8-1 RMySQL_0.10.14 DBI_0.8
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 bindr_0.1.1 magrittr_1.5 lattice_0.20-35 R6_2.2.2 rlang_0.2.0 quadprog_1.5-5 dplyr_0.7.4
[9] tools_3.4.4 grid_3.4.4 assertthat_0.2.0 tibble_1.4.2 bindrcpp_0.2 purrr_0.2.4 codetools_0.2-15 curl_3.1
[17] glue_1.2.0 pillar_1.2.1 cellranger_1.1.0 pkgconfig_2.0.1
我使用的是 XTS 0.10-2 版和 PerformanceAnalytics 1.5.2 版。
解决方案
你的问题在这里得到解决Github PerfomanceAnalytics
第一的:
charts.PerformanceSummary(xts(c(.05,.01,-0.1), as.POSIXct(c('2018-02-28','2018-03-29','2018-04-24'), tz = "UTC")))
第二:
charts.PerformanceSummary(xts(c(.05,.01,-0.1), as.Date(c('2018-02-28','2018-03-29','2018-04-24'))))
推荐阅读
- ios - 如何在 Swift 的多个视图中使用一个活动指示器?
- latex - 我的 LaTex 参考书目对条目进行了两次编号,我不知道为什么
- javascript - 尝试使用 Firebase 存储和 Firestore 数据库上传图片 - 遇到地图错误
- reactjs - 替换目标时停止 mouseenter 触发
- linux - 有什么方法可以将此代码转换为在 Powershell 中工作?Strapi 需要部署到 Heroku
- javascript - 转换 JSON 表单前端,使其符合 API 的预期
- java - 在 Kubernetes 中运行 Mysql 时访问被拒绝
- python - 为什么在两个相似的 DataFrame 上切片工作不同?
- javascript - 在 Chart.js 3.5.0 中隐藏 y 轴上的标签无法正常工作
- wordpress - 控制台浏览器说它找不到我的主机上不存在的请求图像