error in quantmod

Hi
i have a csv file by under column's and when use barchart() get an error

> barChart(f, theme = "white.mono", bar.type = "hlc")
Error in try.xts(x, error = "chartSeries requires an xtsible object") : 
  chartSeries requires an xtsible object

i use as.xts(f) but get another error Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format

str(f)
- attr(*, "spec")=
  .. cols(
  ..   date = col_date(format = ""),
  ..   open = col_double(),
  ..   high = col_double(),
  ..   low = col_double(),
  ..   adjClose = col_double(),
  ..   value = col_double(),
  ..   volume = col_double(),
  ..   count = col_double(),
  ..   close = col_double(),
  ..   jdate = col_date(format = "")
  .. )

> names(f)
 [1] "date"     "open"    
 [3] "high"     "low"     
 [5] "adjClose" "value"   
 [7] "volume"   "count"   
 [9] "close"    "jdate"   
[11] "name"

It would be difficult for us to help you out if we do not have a sample dataset.

data <- data.frame(
                date = c("2016-06-08","2016-06-11",
                         "2016-06-12","2016-06-13","2016-06-14","2016-06-15",
                         "2016-06-18","2016-06-19","2016-06-20",
                         "2016-06-21","2016-06-22"),
                open = c(1780L,1869L,1877L,1880L,
                         1812L,1810L,1840L,1800L,1747L,1790L,1805L),
                high = c(1780L,1869L,1929L,1885L,
                         1823L,1860L,1840L,1809L,1784L,1809L,1858L),
                 low = c(1780L,1869L,1850L,1803L,
                         1802L,1792L,1784L,1732L,1735L,1751L,1795L),
            adjClose = c(1780L,1869L,1885L,1841L,
                         1811L,1822L,1801L,1783L,1780L,1789L,1834L),
               value = c(407068734000,4268257728,
                         209332376085,59648562600,46453577060,21098804085,
                         14614243636,24499567866,20828376254,9413451677,
                         21956446123),
              volume = c(228690300L,2283712L,
                         111028595L,32398615L,25651855L,11577742L,8115891L,
                         13738049L,11699272L,5262841L,11970045L),
               count = c(58797L,852L,46389L,
                         14664L,9559L,4730L,3403L,5942L,3771L,2237L,4298L),
               close = c(1780L,1869L,1881L,1816L,
                         1810L,1840L,1800L,1747L,1784L,1800L,1835L),
               jdate = c("1395-03-19","1395-03-22",
                         "1395-03-23","1395-03-24","1395-03-25","1395-03-26",
                         "1395-03-29","1395-03-30","1395-03-31",
                         "1395-04-01","1395-04-02"),
            name = c("الف","الف","الف","الف","الف","الف","الف","الف","الف","الف","الف" )
        )

I am not sure what exactly you are trying to obtain but the barChart() function in the quantmod package will not work with a data.frame. You need to transform your data in the right format. After creating the dataset in your code above:

barChart(as.xts(ts(data)))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.