The gstlearn R package is a cross-platform R package wrapping the gstlearn C++ Library. It offers to R users all famous Geostatistical methodologies developed and/or invented by the Geostatistic Team of the Geosciences Research Center!
All gstlearn outputs can be ploted using plot generic function which relies on ggplot package.
The gstlearn R package is a R wrapper of the gstlearn C++ Library. It's the successor of the RGeostats R package.
This package contains a modified copy of findR.cmake script (see LICENSE.root in root folder).q
The gstlearn R package is a derivative work based on the swigex0 project: https://github.com/fabien-ors/swigex0
When using the gstlearn R Package, please, use this to cite us in any publication or results for which gstlearn has been used:
--------------------------------------------------
gstlearn
Geostatistics and Machine Learning toolbox
Copyright © MINES Paris - PSL University
Free download from https://gstlearn.org
--------------------------------------------------
You may be interested in the citation file gstlearn.bib
For using this R Package you only need R 4.2 (or higher) and execute the following R command:
install.packages("gstlearn",repos="https://soft.mines-paristech.fr/cran")
Note: With slow Internet connection, you may need to increase the default timeout (60s) (gstlearn package is around 17Mo!)
options(timeout=1000)
We refer the reader to this course page for an introduction and important information about R gstlearn.
# Load gstlearn package
library(gstlearn)
library(ggplot2)
# Grid size
nx = 60
ny = 30
mygrid = DbGrid_create(c(nx,ny), c(1,1))
# Add a gaussian random field
var = rnorm(nx * ny)
mygrid$addColumns(var, "var1", ELoc_Z())
# Display the field
ggplot() + plot.grid(mygrid) + plot.decoration(title="Gaussian random field")
Some tutorials (RMarkdown) are provided in the demo directory here.
Some tests (R Scripts) are available in the tests directory of the gstlearn github repository.
Please, look at CHANGES file.
For building the gstlearn R package, the requirements for building gstlearn C++ library must be installed beforehand. Then, the following additional tools must be also available:
If you modified your system (or if you installed a new version or RTools), you must reinstall the requirements from scratch following next instructions. You must delete 'gstlearn' and 'swig' existing source folders (if so).
Note :
Install gstlearn C++ library requirements for Linux here
Remove any previous installation of SWIG (if any)
Then, execute the following commands:
sudo apt install r-base
sudo apt install bison
sudo apt install pcre2-devel # Ubuntu 18
sudo apt install libpcre2-dev # Ubuntu 20
git clone https://github.com/fabien-ors/swig.git
cd swig
Next time (if a new version of SWIG 4.2.0 [customized] is delivered), you will only need to pull the repository
cd swig
git pull
cmake -Bbuild
cd build
make
sudo make install
install.packages(c("ggplot2", "ggpubr", "knitr", "callr"), repos="https://cloud.r-project.org")
Install gstlearn C++ library requirements for MacOS here
Remove any previous installation of SWIG (if any)
Then, execute the following commands (Not tested):
brew install r
brew install bison
brew install pcre2-devel
git clone https://github.com/fabien-ors/swig.git
cd swig
Next time (if a new version of SWIG 4.2.0 [customized] is delivered), you will only need to pull the repository
cd swig
git pull
cmake -Bbuild
cd build
make
sudo make install
install.packages(c("ggplot2", "ggpubr", "knitr", "callr"), repos="https://cloud.r-project.org")
Note :
Install gstlearn C++ library requirements for Windows (RTools) here
Remove any previous installation of SWIG (if any)
Launch mingw64.exe in RTools installation directory (i.e.: C:\rtools42
) and pin the icon to the task bar
pacman -Sy bison
pacman -Sy mingw-w64-x86_64-pcre2
git clone https://github.com/fabien-ors/swig.git
cd swig
Next time (if a new version of SWIG 4.2.0 [customized] is delivered), you will only need to pull the repository
cd swig
git pull
cmake -G "MSYS Makefiles" -Bbuild -DCMAKE_INSTALL_PREFIX:PATH=/mingw64/
cd build
make
make install
install.packages(c("ggplot2", "ggpubr", "knitr", "callr"), repos="https://cloud.r-project.org")
git clone https://github.com/gstlearn/gstlearn.git
cd gstlearn
Next time, you will only need to pull the repository (If you have some local undesirable modifications, you have to revert them and execute the pull, otherwise do not execute git reset
):
cd gstlearn
git reset --hard
git pull
cmake -Bbuild -S. -DBUILD_R=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --target r_install
or even faster:
make r_install
The check*
targets bring some required runtime customization, so do not use the standard ctest command for triggering the non-regression tests.
To build and launch non-regression R tests, you need to execute the following command:
cmake --build build --target check_r
or even faster:
make check_r
-DCMAKE_INSTALL_PREFIX:PATH=/home/user/Programs/swig4.2.0b
(adapt installation folder) in the cmake
command above.Error: ERROR: no permission to install to directory...
, we suggest you to run the install.packages
command (at least one time). This will create a personal R library folder having writing permissions.-DBUILD_DOXYGEN=ON
to the first cmake command above. Then users will be able to execute make doxygen
.-G "MSYS Makefiles"
to the first cmake command aboveRelease
by Debug
above-DBoost_ROOT="path/to/boost"
-DSWIG_ROOT="path/to/swig"
-DDoxygen_ROOT="path/to/doxygen"
Execute the following command from an R command prompt:
remove.packages("gstlearn")
GPL v3 2023 Team gstlearn