This is a quick example of producing a multiple bar chart using rCharts package via implementing HighCharts library. The original tutorial can be found in rChart Gallery but some functions are outdated as can be checked here - They are updated here.
Firstly rCharts package needs to be installed from the GitHub repo if not installed.
The library is loaded.
The data is shown below.
Food and Tobacco
Medical and Health
The chart can be created as following. Note that the modified part is commented.
Finally it is printed. Note that the results option should be set to be 'asis'.
Note: rCharts package is quite convenient but the chart didn’t show when I pushed it into the blog repo. This was because
the auto-generated script tags were not parsed properly by Jekyll as they were included in a paragraph tag (<p></p>)
the paths were set according to the local paths which cannot be referenced in the remote repo as shown below.
In order to tackle down this issue, the following steps were followed.
Convert the Rmd file into a md file.
Update YAML and add liquid logic in the md file - see here for further details
Commit and push
The upated YAML is shown below.
And the liquid logic used is as following. Note that the quotation marks that wrap % should be stripped out. They are kept as the code is either executed or not apppear correctly together.