Description
Set of functions for the development of R functions and pipelines, written according to the safer-R project specifications.
Content
Read this webpage for more details.
| Function | Description |
|---|---|
| all_args_here() | Check that all the functions used inside a function are written with all their arguments. For instance: base::paste0(letters[1:2], collapse = NULL, recycle0 = FALSE) and not base::paste0(letters[1:2]). Return table message of the line with problems and a corrected version of the submitted function. |
| arg_check() | Check expected values of arguments of functions: class, type, mode, length (each tested exactly, same values, in the same order), restricted values panel, kind of numeric values in addition to the distinction between ‘integer’ and ‘double’ (proportion only? Inf values authorized? negative values authorized? Integers of type ‘double’?). |
| colons_check() | Check that all the functions used inside a function are all referenced by their package attribution. For instance: base::mean() and not mean(), or saferDev:::.base_op_check() and not .base_op_check(). Return table message of the line with problems and a corrected version of the submitted function. |
| curly_bracket_check() | Verify that all the bodies of the if, else, for, while, repeat and function are delimited by curly brackets { }. Return table message of the line with problems and a corrected version of the submitted function. |
| for_loop_nb_check() | Check the sequence expression of every for loop of a function. If the number of iterations is not fixed by the writing itself (e.g., 1:length(x)), a checking line is added before the loop, issuing a warning at execution if the sequence is empty, contains NA or infinite values, has a single value, or is decreasing. Return a table-like message of the problematic lines and a corrected version of the submitted function. |
| lambda_check() | Verify that the lambda functions written with the shorthand \(x) (like \(x) x * 2) are all written with the standard function(x) writing. Return table message of the line with problems and a corrected version of the submitted function. Warning: the \(x) writing is only kept in the code of a function carrying its source references (attribute srcref). |
| env_check() | Verify that object names in the environment defined by the pos argument are identical or not to object names in the above environments (following R Scope). This can be used to verify that names used for objects inside a function or in the working environment do not override names of objects already present in the above R environments, following the R scope. |
| get_message() | Return the error, warning or simple (non error non warning) message if ever exist of an instruction written between quotes. |
| is_function_here() | Check if required functions are present in installed packages. This controls for instance modifications of function names depending on package versions. |
| is_package_here() | Check if required packages are installed locally. |
| report() | Print a character string or a data object into a same log file. |
| true_false_check() | Verify that the TRUE and FALSE logical constants are always written in full when used as values (argument values, conditions, comparisons, indexing) and never abbreviated as T or F, which can be overwritten by the user. Return table message of the line with problems and a corrected version of the submitted function. |
Installation
install.packages("saferDev")Older versions can be installed like this:
v <- "v1.0.0" # desired tag version
remotes::install_github(paste0("https://github.com/safer-r/saferDev@CRAN_/", v))Docker images
SaferDev v1.0.0 alone in R 4.6.0: gmillot/r_v4.6.0_safer_v1.0:gitlab_v11.7
SaferDev v1.0.0 and 295 other packages in R 4.6.0: gmillot/r_v4.6.0_extended_v1.0:gitlab_v11.7
Licence
This package can be redistributed and/or modified under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details at https://www.gnu.org/licenses or in the Licence.txt attached file.
Citation
If you are using functions of saferDev, please cite:
Wang H, Han Y, Legras M, Serizay J, Millot GA (2026). The R saferDev package. https://github.com/safer-r/saferDev/.
Credits
Haiding Wang, Bioinformatics and Biostatistics Hub, Institut Pasteur, Paris, France
Yushi Han, Bioinformatics and Biostatistics Hub, Institut Pasteur, Paris, France
Mia Legras, Bioinformatics and Biostatistics Hub, Institut Pasteur, Paris, France
Jacques Serizay, Spatial Regulation of Genomes team, Institut Pasteur, Paris, France
GLM-5.3, hosted to Institut Pasteur, Paris, France
Gael A. Millot, Bioinformatics and Biostatistics Hub, Institut Pasteur, Paris, France
