[//]:#"#to make links in gitlab: example with racon https://github.com/isovic/racon"
[//]:#"tricks in markdown: https://openclassrooms.com/fr/courses/1304236-redigez-en-markdown"
| usage | R dependencies |
| --- | --- |
| [](https://cran.r-project.org/mirrors.html) | [](https://cran.r-project.org/mirrors.html) |
| [-green?style=plastic)](https://www.gnu.org/licenses) | [](http://www.rforge.net/car/) |
| | [](http://www.rforge.net/carData/) |
| | [](http://www.rforge.net/emmeans/) |
| | [](https://github.com/tidyverse/ggplot2) |
| | [](http://www.rforge.net/lemon/) |
| | [](http://www.rforge.net/lme4/) |
| | [](http://www.rforge.net/lmerTest/) |
| | [](https://github.com/tidyverse/lubridate) |
| | [](http://www.rforge.net/Matrix/) |
| | [](https://gitlab.pasteur.fr/gmillot/cute_little_R_functions) |
## TABLE OF CONTENTS
-[AIM](#aim)
-[REPOSITORY CONTENT](#repository-content)
-[DESCRIPTIONS OF THE FUNCTIONS](#description-of-the-functions)
-[HOW TO HOW TO LOAD AND MANIPULATE](#how-to-load-and-manipulate)
-[VERSIONS](#versions)
-[LICENCE](#licence)
-[CITATION](#citation)
-[CREDITS](#credits)
-[ACKNOWLEDGEMENTS](#Acknowledgements)
-[WHAT'S NEW IN](#what's-new-in)
Cute Little R Functions contains 42 functions for R/RStudio that facilitate basic procedures in 1) object analysis, 2) object modification, 3) graphic handling and 4) log file management.
The function names are:
## AIM
## Object analysis
fun_param_check() #### check class, type, length, etc., of objects
fun_object_info() #### recover object information
fun_1D_comp() #### comparison of two 1D datasets (vectors, factors, 1D tables)
fun_2D_comp() #### comparison of two 2D datasets (row & col names, dimensions, etc.)
fun_2D_head() #### head of the left or right of big 2D objects
fun_2D_tail() #### tail of the left or right of big 2D objects
fun_list_comp() #### comparison of two lists
Set of functions that facilitate basic procedures in 1) object analysis, 2) object modification, 3) graphic handling and 4) log file management.
The present repository of Cute Little R functions is for beta testing. Ultimately, functions will be provided as packages
## Object modification
fun_name_change() #### check a vector of character strings and modify any string if present in another vector
fun_dataframe_remodeling() #### remodeling a data frame to have column name as a qualitative values and vice-versa
fun_refactorization() #### remove classes that are not anymore present in factors or factor columns in data frames
fun_round() #### rounding number if decimal present
| **fun_gg_empty_graph() | text to display for empty graphs |
fun_pack_import() #### check if R packages are present and import into the working environment
fun_python_pack_import() #### check if python packages are present
| Graphic extraction | |
| --- | --- |
| **fun_trim() | display values from a quantitative variable and trim according to defined cut-offs |
| **fun_segmentation() | segment a dot cloud on a scatterplot and define the dots from another cloud outside the segmentation |
| Import | |
| --- | --- |
| **fun_pack() | check if R packages are present and import into the working environment |
| **fun_python_pack() | check if python packages are present |
## Exporting results (text & tables)
| Print / Exporting results (text & tables) | |
| --- | --- |
| **fun_report() | print string or data object into output file |
| **fun_get_message() | return error/warning/other messages of an expression (that can be exported) |
fun_export_data() #### print string or data object into output file
## HOW TO LOAD AND MANIPULATE cute_little_R_functions
Download the desired Tagged version, never the current master, at https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags
#### LICENCE
This package of scripts 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.
For that:
1) Select the desired tagged release
2) Browse files
#### CREDITS
3) Display the cute_little_R_functions.R as raw file
Gael A. Millot, Hub-C3BI, Institut Pasteur, USR 3756 IP CNRS, Paris, France
Description of the functions is at the beginning of the function body. To obtain it:
Either read the cute_little_functions.docx (or open the cute_little_R_functions.R file).
#### HOW TO USE IT
Or in the R/RStudio console, type the name of the function without brackets. Example : `fun_info`.
1) Download the desired Tagged version, never the current master, at https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags
2) Directly source the cute_little_R_functions.R into R/RStudio to have the functions available in the working environment, using for instance source("https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/raw/v6.0.0/cute_little_R_functions.R")
## VERSIONS
Description of the functions is at the beginning of the function body. To obtain it:
Either read the cute_little_functions.docx (or open the cute_little_R_functions.R file).
Or in the R/RStudio console, type the name of the function without brackets. Example : fun_object_info.
The different releases are tagged [here](https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags)
## LICENCE
This package of scripts 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 merchandability or fitness for a particular purpose.
See the GNU General Public License for more details at https://www.gnu.org/licenses.
#### FILE DESCRIPTIONS
cute_little_R_functions.R file that has to be sourced
cute_little_R_functions.docx file that facilitate reading of the function description
examples_alone.txt compile all the examples of the functions into a single file
## CITATION
Not yet published
## CREDITS
#### WEB LOCATION
[Gael A. Millot](https://gitlab.pasteur.fr/gmillot), Hub-CBD, Institut Pasteur, USR 3756 IP CNRS, Paris, France
Check for updated versions (most recent tags) at https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags
## ACKNOWLEDGEMENTS
R and R packages developers
Gitlab developers
#### WHAT'S NEW IN
## WHAT'S NEW IN
## v6.0.0
### v6.0.0
1) name of functions changed:
fun_param_check() fun_check()
fun_object_info() fun_info()
fun_1D_comp() fun_comp_1d()
fun_2D_comp() fun_comp_2d()
fun_list_comp() fun_comp_list()
fun_2D_head() fun_head()
fun_2D_tail() fun_tail()
fun_dataframe_remodeling() fun_df_remod()
fun_by_case_matrix_op() fun_mat_op()
fun_rounding() fun_round()
fun_90clock_matrix_rot() fun_mat_rotate()
fun_hexa_hsv_color_matrix() fun_mat_num2color()
fun_graph_param_prior_plot() fun_prior_plot()
fun_feature_post_plot() fun_post_plot()
fun_window_width_resizing() fun_width()
fun_open_window() fun_open()
fun_close_specif_window() fun_close()
fun_var_trim_display() fun_trim()
fun_export_data() fun_report()
2) new functions added:
fun_name_change()
fun_mat_fill()
fun_permut()
fun_permut_consec()
fun_empty_graph()
fun_gg_palette()
fun_gg_just()
fun_gg_point_rast()
fun_gg_scatter()
fun_gg_bar()
fun_gg_heatmap()
fun_gg_empty_graph()
fun_segmentation()
fun_pack()
fun_python_pack()
fun_warning()
3) text error modified in fun_head() and fun_tail(), + deals without all objects but use head() and tail() if not 2D object
4) in fun_param_check(): (1) has now the class = "vector", (2) argument fun.name added
...
...
@@ -178,69 +262,72 @@ fun_warning()
6) Functions checked for R version 3.6.1
7) function deprecated:
fun_refactorization()
## v5.1.0
### v5.1.0
1) bugs corrected in fun_2D_head() and fun_2D_tail() functions
## v5.0.0
### v5.0.0
1) fun_2D_head() function added
2) fun_2D_tail() function added
3) argument "noquote" added in fun_export_data()
## v4.9.0
### v4.9.0
1) fun_mat_inv() function added
## v4.8.0
### v4.8.0
1) magnific argument removed in fun_feature_post_plot() because no need anymore
## v4.7.0
### v4.7.0
1) check of numeric arguments: class = "numeric" -> mode = "numeric" to allow for integers values in these arguments
## v4.6.0
### v4.6.0
1) fun_by_case_matrix_op() added
## v4.5.0
### v4.5.0
1) fun_open_window() improved to deal with Linux systems
2) fun_graph_param_prior_plot() improved to deal with Linux systems
## v4.4.0
### v4.4.0
1) fun_dataframe_remodeling() now add a ini_rowname column in the output data frame when it is coherent and when initial row names are available (not NULL)
## v4.3.0
### v4.3.0
1) fun_object_info() now manages object class "ordered" "factor"
## v4.2.0
### v4.2.0
1) bug in the fun_2D_comp() function fixed
## v4.1.0
### v4.1.0
1) text.corner replaced by corner.text everywhere
## v4.0.0
### v4.0.0
1) fun_var_trim_display() function added
...
...
@@ -251,14 +338,14 @@ fun_refactorization()
4) error messages now mention the function that generates this message
## v3.1.0
### v3.1.0
1) fun_export_data() function modified: argument data cannot be NULL
2) the debugging line containing r_debugging_tools-v1.2.R updated for the new position of this script
3) more examples added, also draws added in the .docx file for fun_dataframe_remodeling()
## v2.0.1
### v2.0.1
1) functions that use other functions from this toolset now check if these required functions are indeed present in the R environment
## v2.0.0
### v2.0.0
1) fun_feature_post_plot() function improved: Now independent magnification for x axis/labels and y axis/labels. BEWARE: argument names have been modified
...
...
@@ -281,7 +368,13 @@ fun_refactorization()
3) Bug corrected in fun_refactorization() function
## v1.3
### v1.3
Everything
1) fun_1D_comp() function improved: provide the common elements, common names and common levels if exist
# stat.disp: add the median number above the corresponding box. Either NULL (no number shown), "top" (at the top of the plot region) or "above" (above each box)
# stat.disp.mean: logical. Display mean numbers instead of median numbers? Ignored if stat.disp is NULL
# stat.size: numeric value of the stat font size in mm. Ignored if stat.disp is NULL
# stat.dist: numeric value of the stat distance (in the unit of the hjust and vjust arguments of ggplot2::annotate() function). Increase the value to increase the distance from the box plot. Ignored if stat.disp is NULL or "top"
# stat.dist: numeric value of the stat distance in percentage of the y-axis range (stat.dist = 5 means move the number displayed at 5% of the y-axis range). Ignored if stat.disp is NULL or "top"
# stat.angle: integer value of the angle of stat, using the same rules as in ggplot2. Positive values for counterclockwise rotation: 0 for horizontal, 90 for vertical, 180 for upside down etc. Negative values for clockwise rotation: 0 for horizontal, -90 for vertical, -180 for upside down etc.
# vertical: logical. Vertical boxes? WARNING: will be automatically set to TRUE if y.log argument is other than "no". Indeed, not possible to have horizontal boxes with a log axis, due to a bug in ggplot2 (see https://github.com/tidyverse/ggplot2/issues/881)
# text.size: numeric value of the font size of the (1) axis numbers, (2) axis labels and (3) texts in the graphic legend (in mm)
...
...
@@ -8142,8 +8141,7 @@ lib.path = NULL
# $sup.whisker.edge: coordinates of top whisker edges (x and xend)
# $inf.whisker.edge: coordinates of bottom whisker edges(x and xend)
# $mean: diamond mean coordinates (only if box.mean argument is TRUE)
# $stat.display.positive: coordinates of stat numbers when positive (only if stat.disp argument is TRUE)
# $stat.display.negative: coordinates of stat numbers when negative (only if stat.disp argument is TRUE)
# $stat.display: coordinates of stat numbers (only if stat.disp argument is not NULL)
# y.second.tick.positions: coordinates of secondary ticks (only if y.second.tick.nb argument is non-NULL or if y.log argument is different from "no")
# y.second.tick.values: values of secondary ticks. NULL except if y.second.tick.nb argument is non-NULL or if y.log argument is different from "no")
# $panel: the variable names used for the panels (NULL if no panels). WARNING: NA can be present according to ggplot2 upgrade to v3.3.0
stop(paste0("\n\n================\n\n", tempo.cat, "\n\n================\n\n", ifelse(is.null(warn), "", paste0("IN ADDITION\nWARNING", ifelse(warn.count > 1, "S", ""), ":\n\n", warn))), call. = FALSE) # == in stop() to be able to add several messages between ==
ifelse(stat.disp == "top", "bottom", "top"), # "bottom" because we want justification for text that are below the ref point which is the top of the graph. The opposite for "above"
ifelse(stat.disp == "top", "left", "right") # "left" because we want justification for text that are on the left of the ref point which is the right border of the graph. The opposite for "above"
),
kind = "text"
)
}
# has in fact no interest because ggplot2 does not create room for geom_text()
)) # stat$X used here because identical to stat.nolog but has the X. WARNING: no need of order() for labels because box.coord$x set the order. For justification, see https://stackoverflow.com/questions/7263849/what-do-hjust-and-vjust-do-when-making-a-plot-using-ggplot