BwUniCluster2.0/Software/R/stringi: Difference between revisions
(Created page with "= General information = stringi is an R package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding. = Install...") |
|||
Line 50: | Line 50: | ||
<pre> |
<pre> |
||
> library(stringi) |
> library(stringi) |
||
> stri_length(c("Hello", "world", "!") |
> stri_length(c("Hello", "world", "!")) |
||
[1] 5 5 1 |
[1] 5 5 1 |
||
</pre> |
</pre> |
Revision as of 15:11, 17 January 2024
General information
stringi is an R package for fast, portable, correct, consistent, and convenient string/text processing in any locale or character encoding.
Installation
Please enter the following code, presented in the boxes below, directly in your shell/command line on bwUniCluster
Preparations
Prepare .R directory (if it does not already exists). This is then filled with information how R should compile the packages ('compiler flags'). These are written (and can be reviewed) into the (text) file Makevars.
If you already have a .R/Makevars file, check whether these flags are already set.
cat ~/.R/Makevars
In this case, skip the following block of five commands. If this is not the case, enter the following commands in your shell (command line).
mkdir -p ~/.R echo "CXX14=icpc" >> ~/.R/Makevars echo "CXX17=icpc" >> ~/.R/Makevars echo "CXX14FLAGS=-O3 -fPIC -std=c++14 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp" >> ~/.R/Makevars echo "CXX17FLAGS=-O3 -fPIC -std=c++17 -wd308 -axCORE-AVX512,CORE-AVX2,AVX -xSSE4.2 -fp-model strict -qopenmp" >> ~/.R/Makevars echo "CXXFLAGS += -wd308" >> ~/.R/Makevars echo "PKG_CXXFLAGS += -std=c++14 -wd308" >> ~/.R/Makevars
The installation of stringi makes use other libraries (C/C++ and Java libraries for Unicode and globalization, icu4c Intel) which need to be loaded before installation (and R, of course).
module purge module load math/R module load lib/icu4c/74.1_intel2021.4.0
Installing the R package
We can now install stringi (in its development version) and its dependencies within a R session
R -q > install.packages("stringi")
Testing the installation
To check whether the installation worked, make a test run in R
> library(stringi) > stri_length(c("Hello", "world", "!")) [1] 5 5 1
Note that you always need to load
module load math/R/4.1.2 module load lib/icu4c/74.1_intel2021.4.0
to your batch job scripts that use stringi or to run them directly in the command line if you use an interactive session.