Introduction to mschart


Package mschart lets R users to create Microsoft Office charts from data, and then add title, legends, and annotations to the chart object.

Available charts

Names of these high level functions are all prefixed with ms_. The following charts are the only available from all possible MS charts:

Quick start

Call an high level function

We need to call an high level function (one of those starting with ms_). These functions accept the following arguments:

Write charts in Microsoft documents

Let’s have a look at the result by sending it to a new PowerPoint presentation:

Download file barchart_01_stacked.pptx - view with office web viewer

Or in a new Word document:

Download file barchart_01_stacked.docx - view with office web viewer

Customise charts

Charts are generated with default values. Options are available to change charts properties.

The following stack the bars for each group.

my_barchart <- chart_settings( my_barchart, grouping = "stacked", gap_width = 50, overlap = 100 )
my_barchart <- chart_ax_x(my_barchart, cross_between = 'between', 
  major_tick_mark = "in", minor_tick_mark = "none")
my_barchart <- chart_ax_y(my_barchart, num_fmt = "0.00", rotation = -90)
my_barchart <- chart_labels(my_barchart, title = "A main title", 
  xlab = "x axis title", ylab = "y axis title")
my_barchart <- chart_data_fill(my_barchart,
  values = c(serie1 = "#003C63", serie2 = "#ED1F24", serie3 = "#F2AA00") )
my_barchart <- chart_data_stroke(my_barchart, values = "transparent" )