Learn R Programming

⚠️There's a newer version (0.4.0) of this package.Take me there.

mschart R package

The mschart package provides a framework for easily create charts for ‘Microsoft PowerPoint’ documents. It has to be used with package officer that will produce the charts in new or existing PowerPoint or Word documents.

Example

This is a basic example which shows you how to create a line chart.

library(mschart)
library(officer)

linec <- ms_linechart(data = iris, x = "Sepal.Length",
                      y = "Sepal.Width", group = "Species")
linec <- chart_ax_y(linec, num_fmt = "0.00", rotation = -90)

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

doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(doc, value = linec, location = ph_location_type(type = "body"))

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.

Contributing to the package development

A great way to start is to contribute an example or improve the documentation.

If you want to submit a Pull Request to integrate functions of yours, please provide:

  • the new function(s) with code and roxygen tags (with examples)
  • a new section in the appropriate vignette that describes how to use the new function
  • add corresponding tests in directory tests/testthat.

By using rhub (run rhub::check_for_cran()), you will see if everything is ok. When submitted, the PR will be evaluated automatically on travis and appveyor and you will be able to see if something broke.

Copy Link

Version

Install

install.packages('mschart')

Monthly Downloads

1,298

Version

0.2.6

License

MIT + file LICENSE

Maintainer

David Gohel

Last Published

April 7th, 2021

Functions in mschart (0.2.6)

chart_data_symbol

Modify symbol
ms_areachart

areachart object
ms_barchart

barchart object
chart_data_smooth

Smooth series
print.ms_chart

ms_chart print method
chart_data_fill

Modify fill colour
chart_data_stroke

Modify marker stroke colour
set_theme

set chart theme
ms_scatterchart

scatterchart object
ms_linechart

linechart object
chart_labels

Modify axis and plot labels
ph_with.ms_chart

add a MS Chart output into a PowerPoint object
chart_labels_text

Modify labels font settings
chart_settings

set chart options
mschart-defunct

Defunct Functions in Package mschart
chart_data_line_width

Modify line width
as_bar_stack

set a barchart as a stacked barchart
browser_ts

Dummy dataset for barchart
body_add_chart

add chart into a Word document
browser_data

Dummy dataset for barchart
chart_ax_x

axis settings
chart_data_size

Modify symbol size
chart_data_line_style

Modify line style
chart_data_labels

Modify data labels settings