AG1
AG1

Reputation: 6774

R quantmod: how to plot bar charts with >day granularity?

With this code there is a "candlestick" for each day. What is the proper way to modify either getSymbols() or chartSeries() to have a larger granularity? eg. weekly, monthly, quarterly?

library(quantmod)
getSymbols("AAPL")
chartSeries(AAPL, type="candlestick", subset="last 12 months")

enter image description here

Upvotes: 0

Views: 259

Answers (1)

MGs
MGs

Reputation: 290

try this for weekly data:

v <- to.weekly(AAPL)   chartSeries(v, type="candlestick", subset="last 12 months")

or for monthly:

m <- to.monthly(AAPL)  chartSeries(m, type="candlestick", subset="last 12 months")

or for quarterly:

q <- to.quarterly(AAPL) ; chartSeries(q, type="candlestick", subset="last 10 years")

Upvotes: 1

Related Questions