
dX <- structure(c(3272.1,3271.48,3281.03,3267.08,3260.65,NA,1616.3,1620.1,1639.9,1637.4,1669.6,1662.2,528.385,529.268,531.022,532.424,NA),.indexTZ = "",class = c("xts","zoo"),.indexCLASS = c("POSIXct","POSIXt"),tclass = c("POSIXct",tzone = "",index = structure(c(1345147200,1345406400,1345492800,1345579200,1345665600,1345752000),"POSIXt")),.Dim = c(6L,3L),.Dimnames = List(NulL,c("M1WO.Index","GC1.COMB.Comdty","JGAGGUSD.Index"))) 现在试试这段代码:
library(PerformanceAnalytics)library(quantmod)library(timeSerIEs)charts.PerformanceSummary(R = dX)
并得到此错误:
Error in UseMethod("time<-") : no applicable method for 'time<-' applIEd to an object of class "c('xts','zoo')" 我想这个问题是关于class = c(“xts,”zoo“)的数据,但是我不明白为什么它会以那种格式读取那些数据,我怎么能将它强制转换为一个简单的xts对象.
我怎么能解决这个问题?
我的系统:
R version 2.15.1 (2012-06-22)Platform: i386-pc-mingw32/i386 (32-bit)locale:[1] LC_ColLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252[4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages:[1] stats graphics Grdevices datasets utils methods base other attached packages: [1] timeSerIEs_2160.94 timeDate_2160.95 [3] quantmod_0.3-17 TTR_0.21-1 [5] Defaults_1.1-1 PerformanceAnalytics_1.0.4.4 [7] xts_0.8-6 zoo_1.7-7 [9] rcom_2.2-5 rscproxy_2.0-5 loaded via a namespace (and not attached):[1] fBasics_2160.81 fGarch_2110.80.1 grID_2.15.1 lattice_0.20-6 [5] MASS_7.3-18 stabledist_0.6-4 tools_2.15.1
当我加载包时,我得到以下内容:
Loading required package: zooAttaching package: ‘zoo’The following object(s) are masked from ‘package:base’: as.Date,as.Date.numericLoading required package: timeDateAttaching package: ‘timeDate’The following object(s) are masked from ‘package:PerformanceAnalytics’: kurtosis,skewnessAttaching package: ‘timeSerIEs’The following object(s) are masked from ‘package:zoo’: time<-
根据错误信息,我猜这个问题来自于附加timeSerIEs和时间< - 被掩盖了来自package:zoo,我真的不知道它的含义以及如何处理.
解决方法 问题是package timeSerIEs.加载它会发出以下警告:Attaching package: ‘timeSerIEs’The following object(s) are masked from ‘package:zoo’: time<-
您可以分离包以使用charts.PerformanceSummary而不是再次加载它:
detach('package:timeSerIEs')detach('package:timeDate') # since it masks statistical functionscharts.PerformanceSummary(R = dX)library(timeSerIEs) 总结 以上是内存溢出为你收集整理的没有适用于’时间< - '的方法适用于类“c('xts','zoo')的对象”全部内容,希望文章能够帮你解决没有适用于’时间< - '的方法适用于类“c('xts','zoo')的对象”所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)