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,387

Version

0.4.0

License

MIT + file LICENSE

Maintainer

David Gohel

Last Published

November 30th, 2022

Functions in mschart (0.4.0)

chart_settings

set chart options
chart_data_stroke

Modify marker stroke colour
ms_areachart

areachart object
chart_data_symbol

Modify symbol
chart_table

x table settings
chart_labels

Modify axis and plot labels
chart_data_size

Modify symbol size
chart_data_smooth

Smooth series
ms_barchart

barchart object
ph_with.ms_chart

add a MS Chart output into a PowerPoint object
ms_scatterchart

scatterchart object
ms_linechart

linechart object
mschart

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

Index of US Industrial Production
chart_labels_text

Modify labels font settings
print.ms_chart

ms_chart print method
set_theme

set chart theme
body_add_chart

add chart into a Word document
chart_data_labels

Modify data labels settings
chart_data_line_width

Modify line width
browser_ts

Dummy dataset for barchart
chart_ax_x

x axis settings
chart_ax_y

y axis settings
as_bar_stack

set a barchart as a stacked barchart
chart_data_line_style

Modify line style
chart_data_fill

Modify fill colour
browser_data

Dummy dataset for barchart