Although R is essentially a set of statisticals, its use has been extended to a number of areas, such as natural language processing. This library possesses also solic tools of spatial analysis, including analysis of the distributions of points and the Bayesian geostatical modelling. It is possible to read and manage a variety of vector and raster data, including shapefiles, NetCDF and GDAL.
Traditional GIS programs often have been limited by their spatial statistics and their analytical capacity were relatively minor , including a small range of integrated functions, forcing users to use other platforms for advanced analysis, modelling and simulation. ESRI made the acquisition of the MapStudio program from the University of Minsk, which from 2001 has become the Geostatistical Analyst extension of ArcGis .
With R, many popular statistical proceedings and more advanced analyses, including a variety of simulation applications , can be applied directly in tools such as QGIS.
How to install R for QGis.
No need to rush to the QGis processing panel to find R. It is not part of the processing providers included with the QGis installation.
You have to download and install R on your computer before configuring QGis.
Here is the link to download R: https://cran.r-project.org/bin/windows/base/
Once downloaded , double click on the file R-3.3.2-win.exe to install R on your computer .
The program installs R in the directory C: \ Program Files \ R \ R-3.3.2
How to configure the QGis Processing Options To configure R , open the window Options treatments (treatments-> Options …)

Open Treatmentproviders-> R scripts

Check the Activate box to activate the option R and for it to appear in the panel Processing .
If you have a 64bits Windows version, you can check the box Use the 64-bit version . If you have a 32-bit post, only the 32-bit version of R is installed . If you have a 64-bit computer, both versions (32 and 64 bits) are installed . If you do not check the box you will use the same 32-bit version if your PC is a 64 bit.
You have to configure the directory with the library R for QGis. This directory , rlibs lies in C: / User / your username /.qgis2/processing
if it does not exist , create a repertoire rscripts beside rlibs and indicate this repertoire in As Scripts Directory R.
Point the R directory to the directory installation , default C: \ Program Files \ R \ R-3.3.2
Click OK to close the window Treatments Options. You have now the provider R that appears in the processing panel, with two sub-items:

The first Create new R script opens an editing window or you can type a Python script. If you have inputs to set for execution , this is the moment to do it.
The second , Get R scripts from on-line scripts collection , allows you to use Python scripts ready to use with the adequate processing windows already configured .
Let’s see an example . You want to carry out an histogram R for a field of a vector layer . Double- click on Get R scripts from on-line scripts collection to open the window Getscriptsandmodels:

Open item Notinstalled :

Search the tool Histogram , check the corresponding box and click OK. With version 2.18.2 which I use, the processing window will not update immediately. If you open the window again Getscriptsandtemplates you will see a new item in Updateavailable (in the case of the histogram) or item Installed .

When you close this window , the R processing window in the panel is updated, and your new tool is now available under UserR script-> Histogram

If you double click on the tool , you will get the settings window that opens:

When you click on Run , the processing is performed :

If you are not familiar with R, this is the easiest way to start using the tools that R puts at your disposal. If you make a right click on the tool in the processing panel, you can select the option Editthe script to see the construction of the Python script:

Here it is!. We have half-opened a door for you to discover the possibilities that R can bring you.