Search code examples
rquantmod

quantmod barChart cant be displayed


I am using quantmod to get certain shares data displayed.

getSymbols("COP")
barChart(COP)

No problem to displayed the above barChart, but how to go about displaying barchart like this one example below.

 getSymbols("0636.HK")
 barChart(0636.HK)

Error : chartSeries requires an xtsible object

I suspect something to do with numbers or the dot. Any help is appreciated?


Solution

  • library(quantmod)
    
    getSymbols("0636.HK")
    # backticks required according to 
    # http://stackoverflow.com/questions/23807006/deal-with-ticker-name-with-number-in-quantmod
    barChart(`0636.HK`)  
    

    or

    out <- getSymbols("0636.HK", env = NULL)
    barChart(out, name = "0636.HK")
    

    enter image description here