Use the Javascript features for your R charts

Introduction

rAmCharts is an R package for interactive charts. It is based on the javascript library amcharts.js (https://amcharts.com). Currently it implements most of the functionnalities found in the distributions CHARTS and STOCK CHARTS. You’ll find the source code and bug reports on our github page, do not hesitate to send your bugs and your comments.

Based on htmlwidgets, it is compatible with shiny, R Markdown documents and RStudio viewer.

Installation

Package is on CRAN.

install.packages("rAmCharts")

# can have new features in developpement version 
devtools::install_github("datastorm-open/rAmCharts")

Prerequisite

  • The package uses internally pipeR which is usefull to draw complex charts by keeping a certain level of readability in the code. The function mainly used is %>>% (or pipeline()) but the package allow to do many more, see the official tutorial at http://renkun.me/pipeR-tutorial.

For those who are not familiar with the ‘pipe style’ the following lines are equivalent:

head(x = get("iris", "package:datasets"), n = 3)
# or
get("iris", "package:datasets") %>>% head(n = 3)
# or
pipeline(
  get("iris", "package:datasets"),
  head(n = 3)
)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa

Important notice

For all charts generated by R code you’ll see in this introduction, you see a call to the method plot(). It is only necessary for using the package in rmarkdown reports. For other use for instance in the R Studio viewer or shiny applications the method the plot is optionnal.

Find help

  • We have developped few examples in an app with shiny and shinydashboard, run `runExamples()’.

  • If you have some questions about properties to custom a chart you may find solutions in the online amcharts API at https://docs.amcharts.com/3/