I'm having trouble plotting a candlestick chart from a data.frame
file.
Code sample
# Pacotes necessários ----------------------------------------------
library(BatchGetSymbols)
library(quantmod)
# Inputs necessários ------------------------------------------------------
#data inicial
first.date <- as.Date("2018-01-01")
#data final
last.date <- Sys.Date()
#frequencia das observações
freq.data <- 'daily'
# Ativos a serem baixados
tickers <- c("^BVSP")
# Importando ativos -------------------------------------------------------
ibov <- BatchGetSymbols(tickers = tickers,
first.date = first.date,
last.date = last.date,
freq.data = freq.data,
cache.folder = file.path(tempdir(),
'BGS_Cache') )
ibov<-as.data.frame(ibov)
This code imports the data for an example. What I would like to learn would be how to plot this data using the function.
chartSeries
From data.frame ibov
, I tried to do this:
ibov <- xts(ibov, order.by = ibov$df.tickers.ref.date)
chartSeries(ibov)
But the error is appearing:
Error in (function (cl, name, valueClass) :
assignment of an object of class “character” is not valid for @‘yrange’ in
an object of class “chob”; is(value, "numeric") is not TRUE