Learn R Programming

mschart R package

The mschart package provides a framework for easily create charts for ‘Microsoft PowerPoint’ presentations and ‘Microsoft Word’ documents. It has to be used with package officer that will produce the charts in new or existing PowerPoint or Word documents. With ‘Microsoft Charts’, the data is integrated into the document and linked to the chart. The result can be edited, annotated and resized. If the data is updated in the document, the chart is also updated.

Example

This is a basic example which shows you how to create a scatter plot.

library(mschart)
scatter <-
  ms_scatterchart(
    data = iris, x = "Sepal.Length",
    y = "Sepal.Width", group = "Species"
  )
scatter <- chart_settings(scatter, scatterstyle = "marker")

Then use package officer to send the object as a chart.

library(officer)
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(doc, value = scatter, location = ph_location_fullsize())

print(doc, target = "example.pptx")

At any moment, you can type print(your_chart, preview = TRUE) to preview the chart in a temporary PowerPoint file. This requires to have a PowerPoint Viewer installed on the machine.

Installation

You can get the development version from GitHub:

devtools::install_github("ardata-fr/mschart")

Or the latest version on CRAN:

install.packages("mschart")

Contributing to the package

Bug reports

When you file a bug report, please spend some time making it easy for me to follow and reproduce. The more time you spend on making the bug report coherent, the more time I can dedicate to investigate the bug as opposed to the bug report.

Copy Link

Version

Install

install.packages('mschart')

Monthly Downloads

1,068

Version

0.4.1

License

MIT + file LICENSE

Maintainer

David Gohel

Last Published

August 18th, 2025

Functions in mschart (0.4.1)

us_indus_prod

Index of US Industrial Production
print.ms_chart

ms_chart print method
chart_table

x table settings
ms_areachart

areachart object
chart_data_size

Modify symbol size
set_theme

set chart theme
ms_scatterchart

scatterchart object
mschart

Chart Generation for 'Microsoft Word' and 'Microsoft PowerPoint' Documents
theme_ggplot2

Apply ggplot2 theme
chart_data_smooth

Smooth series
chart_data_labels

Modify data labels settings
as_bar_stack

set a barchart as a stacked barchart
browser_data

Dummy dataset for barchart
chart_ax_y

y axis settings
chart_data_line_style

Modify line style
body_add_chart

add chart into a Word document
chart_data_fill

Modify fill colour
chart_ax_x

x axis settings
chart_data_line_width

Modify line width
chart_labels

Modify axis and plot labels
chart_fill_ggplot2

Apply ggplot2 color scale
chart_labels_text

Modify labels font settings
chart_settings

set chart options
ms_linechart

linechart object
chart_data_symbol

Modify symbol
ph_with.ms_chart

add a MS Chart output into a PowerPoint object
chart_data_stroke

Modify marker stroke colour
ms_barchart

barchart object
browser_ts

Dummy dataset for barchart