This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tools:rtools [2021/01/26 16:01] aho [Presentations] |
tools:rtools [2024/02/02 09:23] vagudets |
||
---|---|---|---|
Line 1: | Line 1: | ||
The R tools can be used for postprocessing experiments: | 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 | + | The list of R packages installed in the latest maintained R modules (as of 2024-02-02) can be found {{ : |
A quarterly meeting is taking place in the department to discuss about the plans and priorities of the R tools (or any other topic we need to discuss). Here you can find a document were the minutes are being gathered: | A quarterly meeting is taking place in the department to discuss about the plans and priorities of the R tools (or any other topic we need to discuss). Here you can find a document were the minutes are being gathered: | ||
- | * [[https:// | + | * [[https:// |
+ | * [[https:// | ||
+ | |||
+ | ===== R User Meeting ===== | ||
+ | ====2024==== | ||
+ | * R tools user meeting (Mix Mode, 01/ | ||
+ | ====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 (Online, 08/01/2020) {{ : | + | |
+ | * R tools user meeting (Mix Mode, 04/ | ||
+ | * R tools user meeting (Mix Mode, 07/ | ||
+ | * R tools user meeting (Online, 09/ | ||
+ | * R tools user meeting (Online, 04/ | ||
+ | * R tools user meeting (Online, 07/ | ||
+ | * R tools user meeting (Online, 09/ | ||
+ | * R tools user meeting (Online, 05/ | ||
+ | * R tools user meeting (Online, 05/ | ||
+ | | ||
====2020==== | ====2020==== | ||
Line 20: | Line 57: | ||
* R tools user meeting (BSC, 07/11/2019) {{ : | * R tools user meeting (BSC, 07/11/2019) {{ : | ||
| | ||
- | Please, see specific information for each tool: | + | ===== Packages ===== |
+ | |||
+ | Brief Summary and links to in-house packages: {{ : | ||
+ | |||
+ | See specific information for each tool: | ||
* [[https:// | * [[https:// | ||
Line 30: | Line 71: | ||
* [[https:// | * [[https:// | ||
- | ==== Presentations ==== | ||
- | | + | ===== Presentations ===== |
+ | * {{ : | ||
+ | * {{ : | ||
+ | * {{ : | ||
+ | * {{ : | ||
+ | * {{ : | ||
+ | | ||
* [[https:// | * [[https:// | ||
* {{ : | * {{ : | ||
+ | ===== 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:// | ||
- | ====R Tips==== | ||
- | General R solutions which are useful in the department but doesn' | + | ===== How to source a function from GitLab repository ===== |
- | **1. How to change a CDO version in your open R session** | + | 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: | ||
+ | - git checkout to the branch where the function is. | ||
+ | - 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 ' | ||
+ | |||
+ | BSC-CNS, An-Chi Ho and Nuria Perez-Zanon (2023). s2dv: A Set of | ||
+ | Common Tools for Seasonal to Decadal Verification. R package version | ||
+ | 2.0.0. https:// | ||
+ | |||
+ | 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:// | ||
+ | } | ||
+ | |||
+ | 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, | ||
+ | |||
+ | |||
+ | * **CSTools** | ||
+ | Pérez-Zanón, | ||
+ | |||
+ | * **CSIndicators** | ||
+ | Pérez-Zanón, | ||
+ | |||
+ | |||
+ | * **s2dverification** | ||
+ | Nicolau Manubens, Louis-Philippe Caron, Alasdair Hunter, Omar Bellprat, Eleftheria Exarchou, Neven S. Fučkar, Javier Garcia-Serrano, | ||
+ | |||
+ | |||
+ | ==== Acknowlegement ==== | ||
+ | |||
+ | You can also choose to put the packages in the acknowledgment section. Here is an example from [[https:// | ||
+ | |||
+ | //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.// | ||
+ | |||
+ | |||
+ | ==== 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' | ||
+ | |||
+ | |||
+ | **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. {{ : | ||
+ | |||
+ | |||
+ | **2. How to change a CDO version in your open R session** | ||
Line 57: | Line 230: | ||
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 | ||
- | Note: Avoid to include them in your bashrc, just load them when it is a requirement. | + | (on nord3v2) |
+ | module | ||
+ | module load GDAL/ | ||
+ | module load PROJ/ | ||
+ | module load GEOS/ | ||
+ | |||
+ | (on hub) | ||
+ | module load R/ | ||
+ | module load GDAL/ | ||
+ | module load PROJ/ | ||
+ | module load GEOS/ | ||
- | **3. How to load dependencies of R package rgdal** | + | Note: Avoid to include them in your bashrc, just load them when it is a requirement. |
- | This package could be used by loading the following modules in this specific order: | + | Note2: to use library RNetCDF `module load HDF5/ |
- | - for R 3.2.0: | + | **4. How to load dependencies of R package rgdal** |
- | module | + | |
- | | + | This package could be used by loading the following modules in this specific order: |
- | | + | |
- 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: | ||
module load HDF5/ | module load HDF5/ | ||
+ | | ||
+ | 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 122: | Line 318: | ||
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/ | ||
+ |