简体   繁体   English

R使用PerformanceAnalytics包绘制“ xy.coords(x,y)中的错误”

[英]R plotting “Error in xy.coords(x, y)” using PerformanceAnalytics package

I'm getting error Error in xy.coords(x, y) : 'x' and 'y' lengths differ when plotting xts object RETURNS. 我收到错误Error in xy.coords(x, y) : 'x' and 'y' lengths differ绘制xts对象RETURNS时, Error in xy.coords(x, y) : 'x' and 'y' lengths differ The plotting function used is charts.PerformanceSummary , from the package PerformanceAnalytics . 所使用的绘图功能是来自PerformancePerformance软件包的charts.PerformanceSummary

Would anyone know how to fix this? 有人知道如何解决这个问题吗? It plots regardless of the error, but the presence of an error makes conversion to HTML with knitr package fail. 它会绘制图形,而不考虑错误,但是错误的出现会使使用knitr软件包的HTML转换失败。 Interestingly running the same plotting function on a similar xts object works fine. 有趣的是,在相似的xts对象上运行相同的绘图功能可以正常工作。 I'm baffled. 我很困惑。

library(PerformanceAnalytics)

# THIS PROVIDES THE ERROR:

RETURNS <- structure(c(NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), class = c("xts", "zoo"), index = structure(c(1388448000, 1403474400, 1403475300, 1403476200, 1403477100, 1403478000, 1403478900, 1403479800, 1403480700, 1403481600, 1403482500, 1403483400, 1403484300, 1403485200, 1403486100, 1403487000, 1403487900, 1403488800, 1403489700, 1403490600, 1403491500, 1403492400, 1403493300, 1403494200, 1403495100, 1403496000, 1403496900, 1403497800, 1403498700, 1403499600, 1403500500, 1403501400, 1403502300, 1403503200, 1403504100, 1403505000, 1403505900, 1403506800, 1403507700, 1403508600, 1403509500, 1403510400, 1403511300, 1403512200, 1403513100, 1403514000, 1403514900, 1403515800, 1403516700, 1403517600, 1403518500, 1403519400, 1403520300, 1403521200, 1403522100, 1403523000, 1403523900, 1403524800, 1403525700, 1403526600, 1403527500, 
 1403528400, 1403529300, 1403530200, 1403531100, 1403532000, 1403532900, 1403533800, 1403534700, 1403535600, 1403536500, 1403537400, 1403538300, 1403539200, 1403540100, 1403541000, 1403541900, 1403542800, 1403543700, 1403544600, 1403545500, 1403546400, 1403547300, 1403548200, 1403549100, 1403550000, 1403550900, 1403551800, 1403552700, 1403553600, 1403554500, 1403555400, 1403556300, 1403557200, 1403560800, 1403561700, 1403562600, 1403563500, 1403564400, 1403565300, 1403566200, 1403567100, 1403568000, 1403568900, 1403569800, 1403570700, 1403571600, 1403572500, 1403573400, 1403574300, 1403575200, 1403576100, 1403577000, 1403577900, 1403578800, 1403579700, 1403580600, 1403581500, 1403582400, 1403583300, 1403584200, 1403585100, 1403586000, 1403586900, 1403587800, 1403588700, 1403589600, 1403590500, 1403591400, 1403592300, 1403593200, 1403594100, 1403595000, 1403595900, 1403596800, 1403597700, 1403598600, 1403599500, 1403600400, 1403601300, 1403602200, 1403603100, 1403604000, 1403604900, 1403605800, 1403606700, 1403607600, 1403608500, 1403609400, 1403610300, 1403611200, 1403612100, 1403613000, 1403613900, 1403614800, 1403615700, 1403616600, 1403617500, 1403618400, 1403619300, 1403620200, 1403621100, 1403622000, 1403622900, 1403623800, 1403624700, 1403625600, 1403626500, 1403627400, 1403628300, 1403629200, 1403630100, 1403631000, 1403631900, 1403632800, 1403633700, 1403634600, 1403635500, 1403636400, 1403637300, 1403638200, 1403639100, 1403640000, 1403640900, 1403641800, 1403642700, 1403643600, 1403647200, 1403648100, 1403649000, 1403649900, 1403650800, 1403651700, 1403652600, 1403653500, 1403654400, 1403655300, 1403656200, 1403657100, 1403658000, 1403658900, 1403659800, 1403660700, 1403661600, 1403662500, 1403663400, 1403664300, 1403665200, 1403666100, 1403667000, 1403667900, 1403668800, 1403669700, 1403670600, 1403671500, 1403672400, 1403673300, 1403674200, 1403675100, 1403676000, 1403676900, 1403677800, 1403678700, 1403679600, 1403680500, 1403681400, 1403682300, 1403683200, 1403684100, 1403685000, 1403685900, 1403686800, 1403687700, 1403688600, 1403689500, 1403690400, 1403691300, 1403692200, 1403693100, 1403694000, 1403694900, 1403695800, 1403696700, 1403697600, 1403698500, 1403699400, 1403700300, 1403701200, 1403702100, 1403703000, 1403703900, 1403704800, 1403705700, 1403706600, 1403707500, 1403708400, 1403709300, 1403710200, 1403711100, 1403712000, 1403712900, 1403713800, 1403714700, 1403715600, 1403716500, 1403717400, 1403718300, 1403719200, 1403720100, 1403721000, 1403721900, 1403722800, 1403723700, 1403724600, 1403725500, 1403726400, 1403727300, 1403728200, 1403729100, 1403730000, 1403733600, 1403734500, 1403735400, 1403736300, 1403737200, 1403738100, 1403739000, 1403739900, 1403740800, 1403741700, 1403742600, 1403743500, 1403744400, 1403745300, 1403746200, 1403747100, 1403748000, 1403748900, 1403749800, 1403750700, 1403751600, 1403752500, 1403753400, 1403754300, 1403755200, 1403756100, 1403757000, 1403757900, 1403758800, 1403759700, 1403760600, 1403761500, 1403762400, 1403763300, 1403764200, 1403765100, 1403766000, 1403766900, 1403767800, 1403768700, 1403769600, 1403770500, 1403771400, 1403772300, 1403773200, 1403774100, 1403775000, 1403775900, 1403776800, 1403777700, 1403778600, 1403779500, 1403780400, 1403781300, 1403782200, 1403783100, 1403784000, 
 1403784900, 1403785800, 1403786700, 1403787600, 1403788500, 1403789400, 1403790300, 1403791200, 1403792100, 1403793000, 1403793900, 1403794800, 1403795700, 1403796600, 1403797500, 1403798400, 1403799300, 1403800200, 1403801100, 1403802000, 1403802900, 1403803800, 1403804700, 1403805600, 1403806500, 1403807400, 1403808300, 1403809200, 1403810100, 1403811000, 1403811900, 1403812800, 1403813700, 1403814600, 1403815500, 1403816400, 1403820000, 1403820900, 1403821800, 1403822700, 1403823600, 1403824500, 1403825400, 1403826300, 1403827200, 1403828100, 1403829000, 1403829900, 1403830800, 1403831700, 1403832600, 1403833500, 1403834400, 1403835300, 1403836200, 1403837100, 1403838000, 1403838900, 1403839800, 1403840700, 1403841600, 1403842500, 1403843400, 1403844300, 1403845200, 1403846100, 1403847000, 1403847900, 1403848800, 1403849700, 1403850600, 1403851500, 1403852400, 1403853300, 1403854200, 1403855100, 1403856000, 1403856900, 1403857800, 1403858700, 1403859600, 1403860500, 1403861400, 1403862300, 1403863200, 1403864100, 1403865000, 1403865900, 1403866800, 1403867700, 
 1403868600, 1403869500, 1403870400, 1403871300, 1403872200, 1403873100, 1403874000, 1403874900, 1403875800, 1403876700, 1403877600, 1403878500, 1403879400, 1403880300, 1403881200, 1403882100, 1403883000, 1403883900, 1403884800, 1403885700, 1403886600, 1403887500, 1403888400, 1403889300, 1403890200, 1403891100, 1403892000, 1403892900, 1403893800, 1403894700, 1403895600, 1403896500, 1403897400, 1403898300, 1403899200, 1403900100, 1403901000, 1403901900, 1403902800, 1404079200, 1404080100, 1404081000, 1404081900, 1404082800, 1404083700, 1404084600, 1404085500, 1404086400, 1404087300, 1404088200, 1404089100, 1404090000, 1404090900, 1404091800, 1404092700, 1404093600, 1404094500, 1404095400, 1404096300, 1404097200, 1404098100, 1404099000, 1404099900, 1404100800, 1404101700, 1404102600, 1404103500, 1404104400, 1404105300, 1404106200, 1404107100, 1404108000, 1404108900, 1404109800, 1404110700, 1404111600, 1404112500, 1404113400, 1404114300, 1404115200, 1404116100, 1404117000, 1404117900, 1404118800, 1404119700, 1404120600, 1404121500, 1404122400, 1404123300, 1404124200, 1404125100, 1404126000, 1404126900, 1404127800, 1404128700, 1404129600, 1404130500, 1404131400, 1404132300, 1404133200, 1404134100, 1404135000, 1404135900, 1404136800, 1404137700, 1404138600, 1404139500, 1404140400, 1404141300, 1404142200, 1404143100, 1404144000, 1404144900, 1404145800, 1404146700, 1404147600, 1404148500, 1404149400, 1404150300, 1404151200, 1404152100, 1404153000, 1404153900, 1404154800, 1404155700, 1404156600, 1404157500, 1404158400, 1404159300, 1404160200, 1404161100, 1404162000, 1404165600, 1404166500, 1404167400, 1404168300, 1404169200, 1404170100, 1404171000, 1404171900, 1404172800, 1404173700, 1404174600, 1404175500, 1404176400, 1404177300, 1404178200, 1404179100, 1404180000, 1404180900, 1404181800, 1404182700, 1404183600, 1404184500, 1404185400, 1404186300, 1404187200, 1404188100, 1404189000, 1404189900, 1404190800, 1404191700, 1404192600, 1404193500, 1404194400, 1404195300, 1404196200, 1404197100, 1404198000, 1404198900, 1404199800, 1404200700, 1404201600, 1404202500, 1404203400, 1404204300, 1404205200, 1404206100, 1404207000, 1404207900, 1404208800, 1404209700, 1404210600, 1404211500, 1404212400, 1404213300, 1404214200, 1404215100, 1404216000, 1404216900, 1404217800, 1404218700, 1404219600, 1404220500, 1404221400, 1404222300, 1404223200, 1404224100, 1404225000, 1404225900, 1404226800, 1404227700, 1404228600, 1404229500, 1404230400, 1404231300, 1404232200, 1404233100, 1404234000, 1404234900, 1404235800, 1404236700, 1404237600, 1404238500, 1404239400, 1404240300, 1404241200, 1404242100, 1404243000, 1404243900, 1404244800, 1404245700, 1404246600, 1404247500, 1404248400, 1404252000, 1404252900, 1404253800, 1404254700, 1404255600, 1404256500, 1404257400, 1404258300, 1404259200, 1404260100, 1404261000, 1404261900, 1404262800, 1404263700, 1404264600, 1404265500, 1404266400, 1404267300, 1404268200, 1404269100, 1404270000, 1404270900, 1404271800, 1404272700, 1404273600, 1404274500, 1404275400, 1404276300, 1404277200, 1404278100, 1404279000, 1404279900, 1404280800, 1404281700, 1404282600, 1404283500, 1404284400, 1404285300, 1404286200, 1404287100, 1404288000, 1404288900, 1404289800, 1404290700, 1404291600, 1404292500, 1404293400, 1404294300, 1404295200, 1404296100, 1404297000, 1404297900, 1404298800, 1404299700, 1404300600, 1404301500, 1404302400, 1404303300, 1404304200, 1404305100, 1404306000, 1404306900, 1404307800, 1404308700, 1404309600, 1404310500, 1404311400, 1404312300, 1404313200, 1404314100, 1404315000, 1404315900, 1404316800, 1404317700, 1404318600, 1404319500, 1404320400, 1404321300, 1404322200, 1404323100, 1404324000, 
 1404324900, 1404325800, 1404326700, 1404327600, 1404328500, 1404329400, 1404330300, 1404331200, 1404332100, 1404333000, 1404333900, 1404334800, 1404338400, 1404339300, 1404340200, 1404341100, 1404342000, 1404342900, 1404343800, 1404344700, 1404345600, 1404346500, 1404347400, 1404348300, 1404349200, 1404350100, 1404351000, 1404351900, 1404352800, 1404353700, 1404354600, 1404355500, 1404356400, 1404357300, 1404358200, 1404359100, 1404360000, 1404360900, 1404361800, 1404362700, 1404363600, 1404364500, 1404365400, 1404366300, 1404367200, 1404368100, 1404369000, 1404369900, 1404370800, 1404371700, 1404372600, 1404373500, 1404374400, 1404375300, 1404376200, 1404377100, 1404378000, 1404378900, 1404379800, 1404380700, 1404381600, 1404382500, 1404383400, 1404384300, 1404385200, 1404386100, 1404387000, 1404387900, 1404388800, 1404389700, 1404390600, 1404391500, 1404392400, 1404393300, 1404394200, 1404395100, 1404396000, 1404396900, 1404397800, 1404398700, 1404399600, 1404400500, 1404401400, 1404402300, 1404403200, 1404404100, 1404405000, 1404405900, 1404406800, 1404407700, 1404408600, 1404409500, 1404410400, 1404411300, 1404412200, 1404413100, 1404414000, 1404414900, 1404415800, 1404416700, 1404417600, 1404418500, 1404419400, 1404420300, 1404421200, 1404424800, 1404425700, 1404426600, 1404427500, 1404428400, 1404429300, 1404430200, 1404431100, 1404432000, 1404432900, 1404433800, 1404434700, 1404435600, 1404436500, 1404437400, 1404438300, 1404439200, 1404440100, 1404441000, 1404441900, 1404442800, 1404443700, 1404444600, 1404445500, 1404446400, 1404447300, 1404448200, 1404449100, 1404450000, 1404450900, 1404451800, 1404452700, 1404453600, 1404454500, 1404455400, 1404456300, 1404457200, 1404458100, 1404459000, 1404459900, 1404460800, 1404461700, 1404462600, 1404463500, 1404464400, 1404465300, 1404466200, 1404467100, 1404468000, 1404468900, 1404469800, 1404470700, 1404471600, 1404472500, 1404473400, 1404474300, 1404475200, 1404476100, 1404477000, 1404477900, 1404478800, 1404479700, 1404480600, 1404481500, 1404482400, 1404483300, 1404484200, 1404485100, 1404486000, 1404486900, 1404487800, 1404488700, 1404489600, 1404490500, 1404491400, 1404492300, 1404684000, 1404684900, 1404685800, 1404686700, 1404687600, 1404688500, 1404689400, 1404690300, 1404691200, 1404692100, 1404693000, 1404693900, 1404694800, 1404695700, 1404696600, 1404697500, 1404698400, 1404699300, 1404700200, 1404701100, 1404702000, 1404702900, 1404703800, 1404704700, 1404705600, 1404706500, 1404707400, 1404708300, 1404709200, 1404710100, 1404711000, 1404711900, 1404712800, 1404713700, 1404714600, 1404715500, 1404716400, 1404717300, 1404718200, 1404719100, 1404720000, 1404720900, 1404721800, 1404722700, 1404723600, 1404724500, 1404725400, 1404726300, 1404727200, 1404728100, 1404729000, 1404729900, 1404730800, 1404731700, 1404732600, 1404733500, 1404734400, 1404735300, 1404736200, 1404737100, 1404738000, 1404738900, 1404739800, 1404740700, 1404741600, 1404742500, 1404743400, 1404744300, 1404745200, 1404746100, 1404747000, 1404747900, 1404748800, 1404749700, 1404750600, 1404751500, 1404752400, 1404753300, 1404754200, 1404755100, 1404756000, 1404756900, 1404757800, 1404758700, 1404759600, 1404760500), tzone = "", tclass = c("POSIXct", "POSIXt")), .indexCLASS = c("POSIXct", "POSIXt"), .indexTZ = "", tclass = c("POSIXct", "POSIXt"), tzone = "", .Dim = c(1000L, 1L), .Dimnames = list(NULL, "End.Eq"))
charts.PerformanceSummary(RETURNS, na.rm=T)


# THIS PROVIDES NO ERROR:

RETSBYDAY <- structure(c(0, 0, 0.0131666666666667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), index = structure(c(1403395200, 1403481600, 1403568000, 1403654400, 1403740800, 1403827200, 1.404e+09, 1404086400, 1404172800, 1404259200, 1404345600, 1404432000, 1404604800, 1404691200), tclass = "Date", tzone = "UTC"), .indexCLASS = "Date", .indexTZ = "", tclass = c("POSIXct", "POSIXt"), tzone = "", .Dim = c(14L, 1L), .Dimnames = list(NULL,"DTT3.DailyEndEq"), class = c("xts", "zoo"))
charts.PerformanceSummary(RETSBYDAY)


#RETURNS and RETSBYDAY are 1xN xts objects.
#RETURNS has an NA value and RETSBYDAY has none; including na.rm=T makes no difference.

I don't get an error using performanceanalytics version 1.4.3541. 使用Performanceanalytics版本1.4.3541时没有出现错误。 Perhaps update your version? 也许更新您的版本?

I do get warnings though, that "na.rm is not a graphical parameter" when calling charts.PerformanceSummary with na.rm = TRUE . 我得到警告,虽然,“na.rm不是图形参数”打电话时charts.PerformanceSummaryna.rm = TRUE This warning arises because na.rm = T is passed into the function as an extra parameter (because the function has the special parameter ... ), which is then passed on to the charting functions inside charts.PerformanceSummary , which include chart.CumReturns , chart.BarVaR , and chart.Drawdown , all of which accept passthrough parameters via ... = ... in their function calls inside charts.PerformanceSummary . 之所以会出现此警告,是因为na.rm = T作为附加参数传递到函数中(因为该函数具有特殊参数... ),然后将其传递给charts.PerformanceSummary内部的图表函数,其中包括chart.CumReturnschart.BarVaRchart.Drawdown ,它们全部在charts.PerformanceSummary内部的函数调用中通过... = ...接受chart.Drawdown参数。

You can't assume every function in R will use na.rm = TRUE to remove NAs. 您不能假设R中的每个函数都将使用na.rm = TRUE删除NA。 Just mostly base functions like mean , sum , etc... It would be safer to remove the NAs before passing data to a function, if you get errors arising from the NAs in the function call. 仅是大多数基本函数,例如meansum等。如果在函数调用中由于NA引起的错误,在将数据传递给函数之前删除NA会更安全。 In case you are not aware, this can usually be easily done in a one liner, such as RETURNS <- RETURNS[!is.na(RETURNS),] 如果您不知道,通常可以在一个衬里中轻松完成,例如RETURNS <- RETURNS[!is.na(RETURNS),]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R语言xy.coords(x,y)中的错误 - R language Error in xy.coords(x, y) xy.coords(x,y)中的错误:&#39;x&#39;和&#39;y&#39;的长度不同图表.PerformanceSummary R XTS - Error in xy.coords(x, y) : 'x' and 'y' lengths differ charts.PerformanceSummary R XTS R:xy.coords(x,y,xlabel,ylabel,log)中的错误:&#39;x&#39;和&#39;y&#39;的长度不同 - R: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ xy.coords中的R错误 - R error in xy.coords 用xy.coords在r中绘制坐标 - plotting coordinates in r with xy.coords R 中的逻辑回归使用 glm() 在绘图时在 xy.coords 中产生错误 - Logistic regression in R using glm() produces error in xy.coords when plotting R:xy.coords 中的错误(x,y,xlabel,ylabel,log):“x”是一个列表,但没有组件“x”和“y” - R: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' 情节子图错误:xy.coords(x, y) 中的错误:&#39;x&#39; 是一个列表,但没有组件 &#39;x&#39; 和 &#39;y&#39; - Error with plotly subplot: Error in xy.coords(x, y) : 'x' is a list, but does not have components 'x' and 'y' xy.coords(x,y,xlabel,ylabel,log)中的错误:“ x”是一个列表,但没有组件“ x”和“ y” - Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' 来自 TS 的 HoltWinters 错误“xy.coords(x, y) 中的错误:'x' 和 'y' 长度不同” - Error with HoltWinters from a TS “Error in xy.coords(x, y) : 'x' and 'y' lengths differ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM