简体   繁体   中英

R Quantmod chartSeries() error

I encountered the following error when I tried to execute chartSeries on a daily forex data.

I think the csv dataset should be in order with no missing fields or invalid data in between

A sample of the csv data which was successfully executed with getSymbols()

Date,Open,High,Low,Close,Volume,Adjusted
2005-06-13,1.0796,1.0812,1.0749,1.0791,9456,0
2005-06-14,1.0792,1.0806,1.0784,1.0793,11229,0
2005-06-15,1.0791,1.0799,1.0775,1.0783,9861,0
2005-06-16,1.0785,1.0820,1.0776,1.0813,10687,0
2005-06-17,1.0815,1.0863,1.0796,1.0843,8829,0
2005-06-20,1.0842,1.0864,1.0823,1.0850,8391,0
2005-06-21,1.0853,1.0891,1.0836,1.0879,9864,0

chartSeries(AUDNZD,type="candlestick")

Error :
Error in if(on=="years") {:missing values where TRUE/FALSE needed

I have even added the following options

chartSeries(AUDNZD,type="candlestick",**subset="null",bar.type="olhc", major.ticks="day",plot="true"**) 

to the chartSeries() ,the error then becomes

Error in if (length(c(year,month,day, hour,min,sec))==6 && c(year,:missing values where TRUE/FALSE needed

look as if the time series may be the cause of the error afterall , chartSeries function was somehow trying to determine the correct timeseries scale to apply , the date field was orignially formatted in the string format "yyyy-mm-dd", no idea if this was the correct format or not?

Could anyone help me to resolve the issues please ?

Thanks

here you go

> aud <- read.csv("c:\\aud.csv")
> aud
        Date   Open   High    Low  Close Volume Adjusted
1 2005-06-13 1.0796 1.0812 1.0749 1.0791   9456        0
2 2005-06-14 1.0792 1.0806 1.0784 1.0793  11229        0
3 2005-06-15 1.0791 1.0799 1.0775 1.0783   9861        0
4 2005-06-16 1.0785 1.0820 1.0776 1.0813  10687        0
5 2005-06-17 1.0815 1.0863 1.0796 1.0843   8829        0
6 2005-06-20 1.0842 1.0864 1.0823 1.0850   8391        0
7 2005-06-21 1.0853 1.0891 1.0836 1.0879   9864        0
> aud.xts <- as.xts(zoo(aud[,2:6],order.by=as.Date(aud$Date)))
> chart_Series(aud.xts)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM