R basic template This example shows how to use Anychart library with the R programming language, Shiny web framework and MySQL database.


To use this sample you must have R installed, if not you can visit official R site or follow these instructions; MySQL installed and running, if not please check out MySQL download page and follow these instructions.

To check your installations, run the following command in the command line:

$ R --version
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"... # sample output

$ mysql --version
mysql  Ver 14.14 Distrib 5.5.52, for debian-linux-gnu (x86_64) using readline 6. # sample output

To start this example run commands listed below.

Clone the repository from github.com:

$ git clone git@github.com:anychart-integrations/r-shiny-mysql-template.git

Navigate to the repository folder:

$ cd r-shiny-mysql-template

Set up MySQL database, use -u -p flags to provide username and password:

$  mysql < database_backup.sql

Run R:

$ R

Install application dependencies, one after another and init Shiny:

> install.packages("shiny")

> install.packages("RMySQL")

> install.packages("jsonlite")

> library(shiny)

If you have some troubles with dependencies installation, carefully read error messages, e.g. to install 'RMySQL' you may need:

sudo apt-get install libmysqlclient-dev

Run application supplying absolute path to project folder:

> runApp("{PATH_TO_TEMPLATE}") # e.g. runApp("~/work/r-shiny-mysql-template")

Your browser will open the appliation automatically.


Your workspace should look like:

            style.css       # css style
    app.R                   # main application code
    database_backup.sql     # MySQL database dump
    index.html          # html template


Further Learning


© AnyChart.com - JavaScript charts.
R basic template released under the Apache 2.0 License.