R Statistical Programming Using MariaDB as the Background Database

You are viewing an old version of this article. View the current version here.

Introduction to R

R is a language and environment for statistical computing and graphics. R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …), graphical techniques, machine learning packages and is highly extensible.

One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.

The R environment

R is an integrated suite of software facilities for data manipulation, calculation, and graphical display. It includes:

• an effective data handling and storage facility,

• a suite of operators for calculations on arrays, in particular matrices,

• a large, coherent, integrated collection of intermediate tools for data analysis,

• graphical facilities for data analysis and display either on-screen or on hardcopy, and

• a well-developed, simple and effective programming language which includes conditionals, loops, user-defined recursive functions and input and output facilities.

Using R with MariaDB

R Installation

Some basic notions / tips on how to use R along with MariaDB are the following:

A. The recommended R distribution is “Microsoft R Open”: https://mran.microsoft.com/open/

B. The recommended R GUIs are RStudio Desktop, or RStudio Server: https://www.rstudio.com/products/rstudio/

An alternative would be Microsoft Visual Studio 2015 or 2017: https://www.visualstudio.com/vs/rtvs/

“Microsoft R Open” and “MariaDB Server” can be installed either in the same server, or in different servers, as an ODBC communication protocol will be used for the exchange of data between the two environments.

Data Transfer between R and MariaDB

Package: "odbc"

For the transfer of data between MariaDB Server and R Environment, it is recommended R's "odbc" Package:


  • “odbc" is a new R package available on CRAN (Since 2017-02-05), and maintained by RStudio, which is designed to comply with the DBI specification.

The "odbc" package requires to have previously installed the MariaDB or MySQL ODBC connector:



Other Packages: "readr", "RODBC", "RMariaDB"

There are other alternatives for data transfer between R and MariaDB:

  • “readr” R package, for writing / reading CSV files. To be used in MariaDB along with “LOAD DATA INFILE”.
  • “RMariaDB” R library, a modern 'MariaDB' client based on 'Rcpp': https://github.com/rstats-db/RMariaDB
    • For installing RMariaDB package on 3.4.1+ execute the following R statement: install.packages("RMariaDB")
    • RMariaDB package might require the installation of MariaDB's C Connector, which can be downloaded from: https://downloads.mariadb.org/connector-c/
    • “RMySQL” R library is not recommended for not being robust enough when dealing with “big data” and having too many bugs.

R Programming Resources

A) Programming

Three excellent and recommended books for learning how to program in R are the following:

An extract of the books can be found here:

B) Statistics

An excellent book for understanding the underlying statistics in the R packages is:

C) Statistical / Unsupervised Machine Learning, Deep Learning (Neural Networks) and Artificial Intelligence

The R Programming language has support for the H2O.ai library (h2o), which supports in-memory multi-cluster machine learning models.

For installing R though CRAN, execute: install.packages("h2o")

D) Cheatsheets: Concept Summary

E) Search Engine

  • For searching any R related information, the following web searcher is recommended (Based on Google): http://rseek.org/


Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.