| ms_stockchart | R Documentation |
Creation of a stock chart object that can be inserted
in a 'Microsoft' document. When open is omitted the chart is
a High-Low-Close chart. When open is provided it becomes an
Open-High-Low-Close chart with up/down bars (candlestick).
ms_stockchart(data, x, open = NULL, high, low, close)
data |
a data.frame |
x |
column name for categories (typically dates) |
open |
column name for open values (optional, enables OHLC mode) |
high |
column name for high values |
low |
column name for low values |
close |
column name for close values |
An ms_chart object.
chart_settings(), chart_ax_x(), chart_ax_y(),
chart_theme(), chart_labels()
Other 'Office' chart objects:
ms_areachart(),
ms_barchart(),
ms_boxplotchart(),
ms_bubblechart(),
ms_chart_combine(),
ms_funnelchart(),
ms_histogramchart(),
ms_linechart(),
ms_paretochart(),
ms_piechart(),
ms_radarchart(),
ms_scatterchart(),
ms_sunburstchart(),
ms_treemapchart(),
ms_waterfallchart()
library(officer)
dat <- data.frame(
date = as.Date("2024-01-01") + 0:4,
open = c(44, 25, 38, 50, 34),
high = c(55, 57, 57, 58, 58),
low = c(11, 12, 13, 11, 25),
close = c(32, 35, 34, 35, 43)
)
# HLC chart
stock_hlc <- ms_stockchart(
data = dat, x = "date",
high = "high", low = "low", close = "close"
)
stock_hlc
# OHLC chart (candlestick)
stock_ohlc <- ms_stockchart(
data = dat, x = "date",
open = "open", high = "high",
low = "low", close = "close"
)
stock_ohlc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.