README.md 8.54 KB
Newer Older
Gael  MILLOT's avatar
Gael MILLOT committed
1 2
#### DESCRIPTION

Gael  MILLOT's avatar
Gael MILLOT committed
3
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.
Gael  MILLOT's avatar
Gael MILLOT committed
4

Gael  MILLOT's avatar
Gael MILLOT committed
5
The function names are:
Gael  MILLOT's avatar
Gael MILLOT committed
6

Gael  MILLOT's avatar
Gael MILLOT committed
7 8
## Object analysis

Gael  MILLOT's avatar
Gael MILLOT committed
9 10
fun_param_check() #### check class, type, length, etc., of objects
fun_object_info() #### recover object information
Gael  MILLOT's avatar
Gael MILLOT committed
11 12 13 14 15 16 17 18 19
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


## Object modification

Gael  MILLOT's avatar
Gael MILLOT committed
20
fun_name_change() #### check a vector of character strings and modify any string if present in another vector
Gael  MILLOT's avatar
Gael MILLOT committed
21
fun_dataframe_remodeling() #### remodeling a data frame to have column name as a qualitative values and vice-versa
Gael  MILLOT's avatar
Gael MILLOT committed
22
fun_refactorization() #### remove classes that are not anymore present in factors or factor columns in data frames
Gael  MILLOT's avatar
Gael MILLOT committed
23
fun_round() #### rounding number if decimal present
Gael  MILLOT's avatar
Gael MILLOT committed
24
fun_90clock_matrix_rot() #### 90° clockwise matrix rotation
Gael  MILLOT's avatar
Gael MILLOT committed
25 26
fun_num2color_mat() #### convert a numeric matrix into hexadecimal color matrix
fun_by_case_matrix_op() #### assemble several matrices with operation
Gael  MILLOT's avatar
Gael MILLOT committed
27 28
fun_mat_inv() #### return the inverse of a square matrix
fun_mat_fill() #### fill the empty half part of a symmetric square matrix
Gael  MILLOT's avatar
Gael MILLOT committed
29 30
fun_perm() #### progressively breaks a vector order
fun_perm_consec() #### progressively breaks a vector order
Gael  MILLOT's avatar
Gael MILLOT committed
31 32 33 34

## Graphics management

fun_window_width_resizing() #### window width depending on classes to plot
Gael  MILLOT's avatar
Gael MILLOT committed
35
fun_open_window() #### open a GUI or pdf graphic window
Gael  MILLOT's avatar
Gael MILLOT committed
36 37 38 39
fun_prior_plot() #### set graph param before plotting
fun_scale() #### select nice numbers when setting breaks on an axis
fun_post_plot() #### set graph param after plotting
fun_close_specif_window() #### close specific graphic windows
Gael  MILLOT's avatar
Gael MILLOT committed
40 41 42 43 44 45 46 47 48 49


## Standard graphics

fun_empty_graph() #### text to display for empty graphs


## gg graphics

fun_gg_palette() #### ggplot2 default color palette
Gael  MILLOT's avatar
Gael MILLOT committed
50
fun_gg_just() #### ggplot2 justification of the axis labeling, depending on angle
Gael  MILLOT's avatar
Gael MILLOT committed
51 52
fun_gg_scatter() #### ggplot2 scatterplot + lines (up to 6 overlays totally)
fun_gg_bar_mean() #### ggplot2 mean barplot + overlaid dots if required
Gael  MILLOT's avatar
Gael MILLOT committed
53 54 55 56 57
fun_gg_boxplot() #### ggplot2 boxplot + background dots if required
fun_gg_bar_prop() #### ggplot2 proportion barplot
fun_gg_strip() #### ggplot2 stripchart + mean/median
fun_gg_violin() #### ggplot2 violins
fun_gg_line() #### ggplot2 lines + background dots and error bars
Gael  MILLOT's avatar
Gael MILLOT committed
58 59 60 61 62 63
fun_gg_heatmap() #### ggplot2 heatmap + overlaid mask if required
fun_gg_empty_graph() #### text to display for empty graphs


## Graphic extraction

Gael  MILLOT's avatar
Gael MILLOT committed
64 65
fun_var_trim_display() #### 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
Gael  MILLOT's avatar
Gael MILLOT committed
66 67 68 69


## Import

Gael  MILLOT's avatar
Gael MILLOT committed
70 71
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
Gael  MILLOT's avatar
Gael MILLOT committed
72 73 74 75


## Exporting results (text & tables)

Gael  MILLOT's avatar
Gael MILLOT committed
76
fun_export_data() #### print string or data object into output file
Gael  MILLOT's avatar
Gael MILLOT committed
77

Gael  MILLOT's avatar
Gael MILLOT committed
78 79


Gael  MILLOT's avatar
Gael MILLOT committed
80

Gael  MILLOT's avatar
Gael MILLOT committed
81 82 83 84 85 86 87
#### 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.


Gael  MILLOT's avatar
Gael MILLOT committed
88 89


Gael  MILLOT's avatar
Gael MILLOT committed
90 91 92 93 94
#### CREDITS

Gael A. Millot, Hub-C3BI, Institut Pasteur, USR 3756 IP CNRS, Paris, France


Gael  MILLOT's avatar
Gael MILLOT committed
95 96


Gael  MILLOT's avatar
Gael MILLOT committed
97 98
#### HOW TO USE IT

Gael  MILLOT's avatar
Gael MILLOT committed
99
1) Download the desired Tagged version, never the current master, at https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags
Gael  MILLOT's avatar
Gael MILLOT committed
100

Gael  MILLOT's avatar
Gael MILLOT committed
101
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")
Gael  MILLOT's avatar
Gael MILLOT committed
102

Gael  MILLOT's avatar
Gael MILLOT committed
103
Description of the functions is at the beginning of the function body. To obtain it:
Gael  MILLOT's avatar
Gael MILLOT committed
104

Gael  MILLOT's avatar
Gael MILLOT committed
105
	Either read the cute_little_functions.docx (or open the cute_little_R_functions.R file).
Gael  MILLOT's avatar
Gael MILLOT committed
106
	
Gael  MILLOT's avatar
Gael MILLOT committed
107
	Or in the R/RStudio console, type the name of the function without brackets. Example : fun_object_info.
Gael  MILLOT's avatar
Gael MILLOT committed
108 109


Gael  MILLOT's avatar
Gael MILLOT committed
110 111


Gael  MILLOT's avatar
Gael MILLOT committed
112
#### FILE DESCRIPTIONS
Gael  MILLOT's avatar
Gael MILLOT committed
113

Gael  MILLOT's avatar
Gael MILLOT committed
114
cute_little_R_functions.R	file that has to be sourced
115
cute_little_R_functions.docx	file that facilitate reading of the function description
Gael  MILLOT's avatar
Gael MILLOT committed
116
examples_alone.txt	compile all the examples of the functions into a single file
Gael  MILLOT's avatar
Gael MILLOT committed
117 118


Gael  MILLOT's avatar
Gael MILLOT committed
119 120


Gael  MILLOT's avatar
Gael MILLOT committed
121 122
#### WEB LOCATION

Gael  MILLOT's avatar
Gael MILLOT committed
123
Check for updated versions (most recent tags) at https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags
Gael  MILLOT's avatar
Gael MILLOT committed
124 125


Gael  MILLOT's avatar
Gael MILLOT committed
126 127


Gael  MILLOT's avatar
Gael MILLOT committed
128
#### WHAT'S NEW IN
Gael  MILLOT's avatar
Gael MILLOT committed
129

Gael  MILLOT's avatar
Gael MILLOT committed
130 131 132 133

## v6.0.0

1) name of functions changed:
Gael  MILLOT's avatar
Gael MILLOT committed
134
fun_param_check()	fun_check()
Gael  MILLOT's avatar
Gael MILLOT committed
135
fun_object_info()	fun_info()
Gael  MILLOT's avatar
saving  
Gael MILLOT committed
136 137 138 139 140
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()
Gael  MILLOT's avatar
Gael MILLOT committed
141 142
fun_dataframe_remodeling()	fun_df_remod()
fun_by_case_matrix_op()	fun_mat_op()
Gael  MILLOT's avatar
Gael MILLOT committed
143
fun_rounding()	fun_round()
144 145
fun_90clock_matrix_rot()	fun_mat_rotate()
fun_hexa_hsv_color_matrix()	fun_mat_num2color()
Gael  MILLOT's avatar
Gael MILLOT committed
146 147
fun_graph_param_prior_plot()	fun_prior_plot()
fun_feature_post_plot()	fun_post_plot()
Gael  MILLOT's avatar
Gael MILLOT committed
148 149 150 151
fun_window_width_resizing()	fun_width()
fun_open_window()	fun_open()
fun_close_specif_window()	fun_close()
fun_var_trim_display()	fun_trim()
Gael  MILLOT's avatar
Gael MILLOT committed
152
fun_export_data()	fun_report()
Gael  MILLOT's avatar
Gael MILLOT committed
153 154

2) new functions added:
Gael  MILLOT's avatar
Gael MILLOT committed
155
fun_name_change()
Gael  MILLOT's avatar
Gael MILLOT committed
156
fun_mat_fill()
157
fun_permut()
Gael  MILLOT's avatar
Gael MILLOT committed
158
fun_permut_consec()
Gael  MILLOT's avatar
Gael MILLOT committed
159 160
fun_empty_graph()
fun_gg_palette()
Gael  MILLOT's avatar
Gael MILLOT committed
161
fun_gg_just()
Gael  MILLOT's avatar
saving  
Gael MILLOT committed
162
fun_gg_point_rast()
Gael  MILLOT's avatar
Gael MILLOT committed
163
fun_gg_scatter()
Gael  MILLOT's avatar
saving  
Gael MILLOT committed
164
fun_gg_bar()
Gael  MILLOT's avatar
Gael MILLOT committed
165 166 167
fun_gg_heatmap()
fun_gg_empty_graph()
fun_segmentation()
Gael  MILLOT's avatar
Gael MILLOT committed
168 169
fun_pack()
fun_python_pack()
Gael  MILLOT's avatar
Gael MILLOT committed
170
fun_warning()
Gael  MILLOT's avatar
Gael MILLOT committed
171

Gael  MILLOT's avatar
saving  
Gael MILLOT committed
172
3) text error modified in fun_head() and fun_tail(), + deals without all objects but use head() and tail() if not 2D object
Gael  MILLOT's avatar
Gael MILLOT committed
173 174 175

4) in fun_param_check(): (1) has now the class = "vector", (2) argument fun.name added

Gael  MILLOT's avatar
Gael MILLOT committed
176 177
5) writting and debugging message errors improved in all the functions

Gael  MILLOT's avatar
Gael MILLOT committed
178 179 180 181
6) Functions checked for R version 3.6.1

7) function deprecated:
fun_refactorization()
Gael  MILLOT's avatar
Gael MILLOT committed
182 183


Gael  MILLOT's avatar
Gael MILLOT committed
184 185 186 187 188
## v5.1.0

1) bugs corrected in fun_2D_head() and fun_2D_tail() functions


Gael  MILLOT's avatar
Gael MILLOT committed
189 190 191 192 193 194 195
## v5.0.0

1) fun_2D_head() function added
2) fun_2D_tail() function added
3) argument "noquote" added in fun_export_data()


Gael  MILLOT's avatar
Gael MILLOT committed
196 197 198 199 200
## v4.9.0

1) fun_mat_inv() function added


Gael  MILLOT's avatar
Gael MILLOT committed
201 202 203 204 205
## v4.8.0

1) magnific argument removed in fun_feature_post_plot() because no need anymore


Gael  MILLOT's avatar
Gael MILLOT committed
206 207 208 209 210
## v4.7.0

1) check of numeric arguments: class = "numeric" -> mode = "numeric" to allow for integers values in these arguments


Gael  MILLOT's avatar
Gael MILLOT committed
211 212 213 214 215
## v4.6.0

1) fun_by_case_matrix_op() added


Gael  MILLOT's avatar
Gael MILLOT committed
216 217 218 219 220 221 222
## 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


Gael  MILLOT's avatar
Gael MILLOT committed
223 224 225 226 227
## 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)


Gael  MILLOT's avatar
Gael MILLOT committed
228 229 230 231 232
## v4.3.0

1) fun_object_info() now manages object class "ordered" "factor"


Gael  MILLOT's avatar
Gael MILLOT committed
233 234 235 236 237
## v4.2.0

1) bug in the fun_2D_comp() function fixed


Gael  MILLOT's avatar
Gael MILLOT committed
238 239 240 241 242
## v4.1.0

1) text.corner replaced by corner.text everywhere


Gael  MILLOT's avatar
Gael MILLOT committed
243 244 245 246 247 248 249 250 251 252 253
## v4.0.0

1) fun_var_trim_display() function added

2) fun_feature_post_plot() function now provides additional coordinates when there are margins between the figure region and the device region

3) fun_2D_comp() function now provide the common row and column names, and a bug fixed in the detection of identical row or column content

4) error messages now mention the function that generates this message 


Gael  MILLOT's avatar
Gael MILLOT committed
254 255 256 257 258 259 260
## 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


Gael  MILLOT's avatar
Gael MILLOT committed
261 262
## v3.0.0

Gael  MILLOT's avatar
Gael MILLOT committed
263
1) cute_little_functions.R renamed cute_little_R_functions.R
Gael  MILLOT's avatar
Gael MILLOT committed
264

Gael  MILLOT's avatar
Gael MILLOT committed
265 266
2) function fun_dataframe_flipping() has been renamed fun_dataframe_remodeling()

Gael  MILLOT's avatar
Gael MILLOT committed
267
3) more examples added, also draws added in the .docx file for fun_dataframe_remodeling()
Gael  MILLOT's avatar
Gael MILLOT committed
268 269


Gael  MILLOT's avatar
Gael MILLOT committed
270 271 272 273 274
## 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


Gael  MILLOT's avatar
Gael MILLOT committed
275 276 277 278 279 280 281 282 283 284 285
## 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

2) Bug corrected in fun_graph_param_prior_plot() function

3) Bug corrected in fun_refactorization() function


## v1.3

Gael  MILLOT's avatar
Gael MILLOT committed
286
1) fun_1D_comp() function improved: provide the common elements, common names and common levels if exist
Gael  MILLOT's avatar
Gael MILLOT committed
287 288