This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tools:rtools [2021/11/04 11:59] aho [2021] |
tools:rtools [2024/09/12 12:27] (current) vagudets [2024] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | The R tools can be used for postprocessing experiments: | + | At BSC-ES there is a collaborative effort to share resources for data analysis in R and develop some in-houseR tools that are maintained by the R developer team. The R tools can be used for postprocessing experiments: |
- | You can join the [[http:// | + | You can join the [[http:// |
- | The list of functions in each department R package and the R modules with library versions can be found [[https:// | + | ===== Getting started: using R at BSC-ES ===== |
- | A quarterly | + | ==== Environment Modules ==== |
- | * [[https:// | + | |
+ | The Workstations, | ||
+ | |||
+ | For example, to load CDO and R in the workstation, | ||
+ | module load CDO/ | ||
+ | module load R/ | ||
+ | |||
+ | The currently maintained R module versions are: | ||
+ | |||
+ | * Workstations: | ||
+ | * BSC-ES Hub: R/ | ||
+ | * Nord3v2: R/ | ||
+ | * CTE-AMD: R/ | ||
+ | |||
+ | Check the wiki page for each machine to see if you need to follow any additional steps to be able to load the correct modules. | ||
+ | |||
+ | ==== R packages ==== | ||
+ | |||
+ | The R modules contain the latest released version of our in-house R packages, as well as many other R packages that may be used by people in the department. | ||
+ | There is no need to install any packages locally by yourself; you can load the corresponding module and check if the R package is already installed. If it is not installed, you may open an issue in the Requests GitLab project (https:// | ||
+ | |||
+ | Some packages may require additional modules; see the ‘R tips’ section below. | ||
+ | |||
+ | The list of R packages installed in the latest maintained R modules (as of 2024-02-02) can be found {{ : | ||
+ | |||
+ | ==== Where to run R ==== | ||
+ | |||
+ | * To open an R session in the terminal, simply type ‘R’ after loading the R module. | ||
+ | * RStudio Server is available on the Workstations and Nord3v2. See the section ‘RStudio Server’ below. RStudio Server is not yet available on the Hub, but you can use VSCode. See the ‘R tips’ section below. | ||
+ | * To use Jupyter Notebooks in the BSC-ES Hub, see the [[https:// | ||
+ | |||
+ | ===== R User Meeting ===== | ||
+ | |||
+ | A monthly | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ====2024==== | ||
+ | * R tools user meeting (Hybrid Mode, 01/ | ||
+ | * R tools user meeting (Hybrid Mode, 04/ | ||
+ | * R tools user meeting (Hybrid Mode, 02/ | ||
+ | * R tools user meeting (Hybrid Mode, 01/ | ||
+ | * R tools user meeting (Hybrid Mode, 04/ | ||
+ | * R tools user meeting (Hybrid Mode, 09/ | ||
+ | ====2023==== | ||
+ | * R tools user meeting (Mix Mode, 14/ | ||
+ | * R tools user meeting (Mix Mode, 02/ | ||
+ | * R tools user meeting (Mix Mode, 05/ | ||
+ | * R tools user meeting (Mix Mode, 07/ | ||
+ | * R tools user meeting (Mix Mode, 06/ | ||
+ | * R tools user meeting (Mix Mode, 01/ | ||
+ | * R tools user meeting (Mix Mode, 04/ | ||
+ | * R tools user meeting (Mix Mode, 06/ | ||
+ | * R tools user meeting (Mix Mode, 02/ | ||
+ | * R tools user meeting (Mix Mode, 02/ | ||
+ | |||
+ | ====2022==== | ||
+ | * R tools user meeting (Mix Mode, 01/ | ||
+ | * R tools user meeting (Mix Mode, 03/ | ||
+ | * R tools user meeting (Mix Mode, 06/ | ||
+ | * R tools user meeting (Mix Mode, 01/ | ||
+ | * R tools user meeting (Mix Mode, 07/ | ||
+ | * R tools user meeting (Mix Mode, 02/ | ||
+ | * R tools user meeting (Mix Mode, 05/ | ||
+ | * R tools user meeting (Mix Mode, 07/ | ||
+ | * R tools user meeting (Mix Mode, 03/ | ||
+ | * R tools user meeting (Mix Mode, 03/ | ||
====2021==== | ====2021==== | ||
+ | * R tools user meeting (Mix Mode, 02/ | ||
* R tools user meeting (Mix Mode, 04/ | * R tools user meeting (Mix Mode, 04/ | ||
* R tools user meeting (Mix Mode, 07/ | * R tools user meeting (Mix Mode, 07/ | ||
Line 28: | Line 95: | ||
* R tools user meeting (BSC, 07/11/2019) {{ : | * R tools user meeting (BSC, 07/11/2019) {{ : | ||
| | ||
- | Please, see specific information for each tool: | + | ===== In-house Packages ===== |
+ | |||
+ | Brief Summary and links to in-house packages: {{ : | ||
+ | |||
+ | See specific information for each tool: | ||
* [[https:// | * [[https:// | ||
Line 38: | Line 109: | ||
* [[https:// | * [[https:// | ||
- | ==== Presentations ==== | ||
- | | + | ===== Presentations ===== |
+ | * {{ : | ||
+ | * {{ : | ||
+ | * {{ : | ||
+ | * {{ : | ||
+ | * {{ : | ||
+ | | ||
* [[https:// | * [[https:// | ||
* {{ : | * {{ : | ||
- | ====How to cite==== | + | ===== How to report an issue ===== |
+ | We use issues to identify and address bugs and propose new developments in the codebase. If you find a problem in our tools, please read this document to see if you should and how to report an issue. [[https:// | ||
- | If you are using any of the R packages being developed at the department, you can include a citation in your research items. | ||
- | | + | ===== How to source a function from GitLab repository ===== |
- | BSC-CNS and Nicolau Manubens | + | |
+ | If we want to test a developing function from GitLab, sourcing the file on GitLab is very useful. Of course, you can save the file and source it locally, but when the file is updated, you need to manually update the local file, which is not convenient. | ||
+ | |||
+ | If the repository is **public**, you can follow these two ways. | ||
+ | |||
+ | 1. If you have the git repo cloned under your personal directory: | ||
+ | | ||
+ | - Open an R session, source the function from the git repo. Source the depended packages as well. You can modify the following lines for your package. | ||
+ | |||
+ | path <- "/ | ||
+ | ff <- lapply(list.files(path), | ||
+ | invisible(lapply(ff, | ||
+ | # load all the depended packages | ||
+ | lib <- c(' | ||
+ | invisible(lapply(lib, | ||
+ | |||
+ | 2. If you don't have a local git repo: | ||
+ | |||
+ | | ||
+ | source(" | ||
+ | |||
+ | Remember that you need to use the raw URL, which can be found in the upper-right corner of the file. | ||
+ | Note that you may need to load other packages or source other functions used in the sourced function. In contrast, by the first method above, all the possible needs are taken care of already. | ||
+ | |||
+ | If the repository is **not public**, see {{ : | ||
+ | |||
+ | ===== How to cite R Tools ===== | ||
+ | |||
+ | If you use any R packages, both developed in or outside of the department, you can include a citation in your research items. | ||
+ | |||
+ | // | ||
+ | |||
+ | ==== Cite R package ==== | ||
+ | To get the most updated citation text, you can simply use R function " | ||
+ | |||
+ | > citation(" | ||
+ | To cite package ' | ||
+ | |||
+ | | ||
+ | Common Tools for Seasonal to Decadal Verification. R package version | ||
+ | | ||
+ | |||
+ | A BibTeX entry for LaTeX users is | ||
+ | |||
+ | @Manual{, | ||
+ | title = {s2dv: A Set of Common Tools for Seasonal to Decadal Verification}, | ||
+ | author = {{BSC-CNS} and An-Chi Ho and Nuria Perez-Zanon}, | ||
+ | year = {2023}, | ||
+ | note = {R package version 2.0.0}, | ||
+ | url = {https://CRAN.R-project.org/package=s2dv}, | ||
+ | } | ||
+ | |||
+ | Notice that you may want to change the version number in case the research is done with a previous version. | ||
+ | |||
+ | ==== Cite R ==== | ||
+ | To cite R software along with its base packages, type citation(). The year varies with the R version you use. | ||
+ | |||
+ | > citation() | ||
+ | To cite R in publications use: | ||
+ | |||
+ | R Core Team (2021). R: A language and environment for statistical | ||
+ | computing. R Foundation for Statistical Computing, Vienna, Austria. | ||
+ | URL https:// | ||
+ | |||
+ | A BibTeX entry for LaTeX users is | ||
+ | |||
+ | @Manual{, | ||
+ | title = {R: A Language and Environment for Statistical Computing}, | ||
+ | author = {{R Core Team}}, | ||
+ | organization = {R Foundation for Statistical Computing}, | ||
+ | address = {Vienna, Austria}, | ||
+ | year = {2021}, | ||
+ | url = {https:// | ||
+ | } | ||
+ | |||
+ | We have invested a lot of time and effort in creating R, please cite it | ||
+ | when using it for data analysis. See also ‘citation(" | ||
+ | citing R packages. | ||
+ | |||
+ | |||
+ | ==== Package publication ==== | ||
+ | |||
+ | Some packages have their own publication, | ||
- | * **ClimProjDiags** | ||
- | N. Pérez-Zanón, | ||
* **CSTools** | * **CSTools** | ||
- | | + | Pérez-Zanón, |
* **CSIndicators** | * **CSIndicators** | ||
- | Pérez-Zanón, | + | Pérez-Zanón, |
- | + | ||
* **s2dverification** | * **s2dverification** | ||
Nicolau Manubens, Louis-Philippe Caron, Alasdair Hunter, Omar Bellprat, Eleftheria Exarchou, Neven S. Fučkar, Javier Garcia-Serrano, | Nicolau Manubens, Louis-Philippe Caron, Alasdair Hunter, Omar Bellprat, Eleftheria Exarchou, Neven S. Fučkar, Javier Garcia-Serrano, | ||
- | * **s2dv** | ||
- | BSC-CNS, An-Chi Ho and Núria Pérez-Zanón (2020). s2dv: A Set of Common Tools for Seasonal to Decadal Verification. R package version 0.1.0. https:// | ||
- | |||
- | * Given that these packages are using **R environment**, | ||
- | R Core Team (2019). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https:// | ||
- | //**Note** that the version of R and packages can be updated, you can check the latest reference by open a terminal and running `citation()` for the R version and `citation(" | + | ==== Acknowlegement ==== |
- | Finally, it is recommended | + | You can also choose |
//We acknowledge the use of the s2dverification (Manubens et al. 2018), startR (BSC/CNS and Manubens 2020), SpecsVerification (Siegert 2017), CSTools (Pérez-Zanón et al. 2019), ClimProjDiags (BSC/CNS et al. 2020), and boot (Davison and Hinkley 1997; Canty and Ripley 2020) R (R Core Team 2013) software packages.// | //We acknowledge the use of the s2dverification (Manubens et al. 2018), startR (BSC/CNS and Manubens 2020), SpecsVerification (Siegert 2017), CSTools (Pérez-Zanón et al. 2019), ClimProjDiags (BSC/CNS et al. 2020), and boot (Davison and Hinkley 1997; Canty and Ripley 2020) R (R Core Team 2013) software packages.// | ||
- | ====R Tips==== | + | |
+ | ==== Manuscript ==== | ||
+ | |||
+ | It is recommended to add some sentences in the manuscripts where readers can check the full list of software used. For example, | ||
+ | |||
+ | //All analyses were performed using R Statistical Software (v4.1.2; R Core Team 2021). Temperature data was processed via the R packages: startR (v2.3.0; BSC-CNS etc. 2023), s2dv (v2.0.0; BSC-CNS etc. 2023). The indices were calculated using the R package: CSIndicators (v1.0.1; N. Perez etc. 2023).// | ||
+ | |||
+ | ===== RStudio-server ===== | ||
+ | |||
+ | You can launch RStudio-server on workstation or on Nord3v2. It opens RStudio IDE as a webpage. Please follow the instruction: | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== R Tips ===== | ||
General R solutions that are useful in the department but doesn' | General R solutions that are useful in the department but doesn' | ||
- | **1. How to change a CDO version in your open R session** | + | |
+ | **1. BSC-ES infrastructure** | ||
+ | |||
+ | |||
+ | How to access, what you will find (servers, machines, partitions, modules) and how to open RStudio: check the slides and share them with your colleagues. {{ : | ||
+ | |||
+ | How to access BSC Hub and run R from the terminal and using VSCode: {{ : | ||
+ | |||
+ | |||
+ | **2. How to change a CDO version in your open R session** | ||
Line 96: | Line 270: | ||
in your terminal | in your terminal | ||
- | **2. How to load dependencies of R package sf** | + | **3. How to load dependencies of R package sf, terra, and mapview** |
- | This package could be used by loading the following modules | + | This package could be used by loading the following modules |
- | | + | (on workstation) |
- | module load GDAL/ | + | |
- | module load PROJ/6.1.1-foss-2015a | + | module load GDAL/ |
- | module load GEOS/3.8.0-foss-2015a | + | module load PROJ/4.8.0-foss-2015a |
+ | module load GEOS/3.7.2-foss-2015a-Python-2.7.9 | ||
+ | |||
+ | (on nord3v2) | ||
+ | module load R/ | ||
+ | module load GDAL/3.3.2-foss-2019b-Python-3.7.4 | ||
+ | module load PROJ/7.2.1-foss-2019b | ||
+ | module load GEOS/3.7.2-foss-2019b-Python-3.7.4 | ||
+ | |||
+ | (on hub) | ||
+ | module load R/ | ||
+ | module load GDAL/ | ||
+ | module load PROJ/9.1.0-foss-2021b | ||
+ | module load GEOS/ | ||
+ | |||
+ | Note: Avoid to include them in your bashrc, just load them when it is a requirement. | ||
- | Note: Avoid to include them in your bashrc, just load them when it is a requirement. | ||
Note2: to use library RNetCDF `module load HDF5/ | Note2: to use library RNetCDF `module load HDF5/ | ||
- | **3. How to load dependencies of R package rgdal** | + | **4. How to load dependencies of R package rgdal** |
This package could be used by loading the following modules in this specific order: | This package could be used by loading the following modules in this specific order: | ||
- | |||
- | - for R 3.2.0: | ||
- | module load R/ | ||
- | module load GDAL/ | ||
- | module load PROJ/ | ||
- for R 3.6.1: | - for R 3.6.1: | ||
module load R/ | module load R/ | ||
module load GDAL/ | module load GDAL/ | ||
- | # if necessary add: module load PROJ/5.0.1-foss-2015a | + | # if necessary add: module load PROJ/6.1.1-foss-2015a |
+ | |||
+ | - for R 4.1.2: | ||
+ | module load R/ | ||
+ | module load GDAL/ | ||
+ | # if necessary add: module load PROJ/6.1.1-foss-2015a | ||
- | Note: Avoid to include | + | Note: Avoid including |
- | **4. How to avoid Load error in R 3.6.1: | + | **5. How to avoid Load error in R 3.6.1: |
To avoid an error of Load because of the command CDO -griddes, a different version of HDF5 is required: | To avoid an error of Load because of the command CDO -griddes, a different version of HDF5 is required: | ||
Line 132: | Line 320: | ||
The same requirement also applies to s2dv:: | The same requirement also applies to s2dv:: | ||
- | **5. How to use ' | + | **6. How to use ' |
- | To correctly use the R library rmapshaper | + | To correctly use the R library rmapshaper, |
- | | + | - On workstation: |
+ | | ||
+ | module load libprotobuf/ | ||
+ | |||
+ | - On Nord3v2: | ||
+ | module load R/ | ||
+ | module load protobuf/ | ||
- | **6. How to avoid plotting issues (as fuzzy labels) in Nord3** | + | **7. How to avoid plotting issues (as fuzzy labels) in Nord3** |
To save good quality plots created in Nord3, the library ' | To save good quality plots created in Nord3, the library ' | ||
Line 164: | Line 358: | ||
dev.off() | dev.off() | ||
- | **7. Error *** caught segfault *** address 0x18, cause ' | + | **8. Error *** caught segfault *** address 0x18, cause ' |
If this error appears, check that the partition `/dev/shm/` is empty. In case, trash files are occupying this partition, the process you are running may fail. **Remove the files and re-run your code.** | If this error appears, check that the partition `/dev/shm/` is empty. In case, trash files are occupying this partition, the process you are running may fail. **Remove the files and re-run your code.** | ||
If the error persists, **check your code with a smaller data sample** to discard a problem with your code since this error message indicates that you are requesting more memory than the available. | If the error persists, **check your code with a smaller data sample** to discard a problem with your code since this error message indicates that you are requesting more memory than the available. | ||
+ | |||
+ | **9. Special characters ** | ||
+ | |||
+ | In case of problems with accents or special characters, try to change the R session language to the most convenient: `Sys.setlocale(" | ||
+ | |||
+ | **10. Test the development on Git** | ||
+ | |||
+ | There are several ways to source the functions under development. Depending on the attributes of the function and the use case, the most suitable way can vary. Check the slides: {{ : | ||
+ | |||
+ | **11. How to load dependencies of R package RNetCDF** | ||
+ | |||
+ | This package could be used by loading the following modules (note that order may affect): | ||
+ | |||
+ | (on workstation) | ||
+ | module load R/ | ||
+ | module load HDF5/ | ||
+ | |||
+ | (on nord3v2) | ||
+ | module load R/ | ||
+ | module load HDF5/ | ||
+ |