README.md 11.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[//]: # "#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 |
| --- | --- |
| [![R Version](https://img.shields.io/badge/code-R-blue?style=plastic)](https://cran.r-project.org/mirrors.html) | [![Dependencies: R Version](https://img.shields.io/badge/R-v4.0.2-blue?style=plastic)](https://cran.r-project.org/mirrors.html) |
| [![License: GPL-3.0](https://img.shields.io/badge/licence-GPL%20(%3E%3D3)-green?style=plastic)](https://www.gnu.org/licenses) | [![Dependencies: R Package](https://img.shields.io/badge/package-car%20v3.0.9-blue?style=plastic)](http://www.rforge.net/car/) |
| | [![Dependencies: R Package](https://img.shields.io/badge/package-carData%20v3.0.4-blue?style=plastic)](http://www.rforge.net/carData/) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-emmeans%20v1.5.0-blue?style=plastic)](http://www.rforge.net/emmeans/) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-ggplot2%20v3.3.2-blue?style=plastic)](https://github.com/tidyverse/ggplot2) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-lemon%20v0.4.5-blue?style=plastic)](http://www.rforge.net/lemon/) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-lme4%20v1.1.23-blue?style=plastic)](http://www.rforge.net/lme4/) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-lmerTest%20v3.1.2-blue?style=plastic)](http://www.rforge.net/lmerTest/) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-lubridate%20v1.7.9-blue?style=plastic)](https://github.com/tidyverse/lubridate) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/package-Matrix%20v1.2.18-blue?style=plastic)](http://www.rforge.net/Matrix/) |
|  | [![Dependencies: R Package](https://img.shields.io/badge/toolbox-cute%20little%20R%20functions%20v6.0.0-blue?style=plastic)](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)
Gael  MILLOT's avatar
Gael MILLOT committed
31

Gael  MILLOT's avatar
Gael MILLOT committed
32

33
## AIM
Gael  MILLOT's avatar
Gael MILLOT committed
34

Gael  MILLOT's avatar
Gael MILLOT committed
35

36
Set of functions 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
37

38
The present repository of Cute Little R functions is for beta testing. Ultimately, functions will be provided as packages
Gael  MILLOT's avatar
Gael MILLOT committed
39
40


41
## REPOSITORY CONTENT
Gael  MILLOT's avatar
Gael MILLOT committed
42

43
**cute_little_R_functions.R** file that has to be sourced in R or RStudio
Gael  MILLOT's avatar
Gael MILLOT committed
44

45
**cute_little_R_functions.docx** same as cute_little_R_functions.R but for better reading (interactive outline at the beginning of the file)
Gael  MILLOT's avatar
Gael MILLOT committed
46

47
**examples.R** examples of all the functions, except fun_gg_boxplot() and fun_gg_scatter(), that can be sourced or copied-pasted
Gael  MILLOT's avatar
Gael MILLOT committed
48

49
**boxplot_examples.R** examples of fun_gg_boxplot() that can be sourced or copied-pasted
Gael  MILLOT's avatar
Gael MILLOT committed
50

51
**scatter_examples.R** examples of fun_gg_scatter() that can be sourced or copied-pasted
Gael  MILLOT's avatar
Gael MILLOT committed
52

53
**other** folder containing avorted developments
Gael  MILLOT's avatar
Gael MILLOT committed
54
55


56
## DESCRIPTIONS OF THE FUNCTIONS
Gael  MILLOT's avatar
Gael MILLOT committed
57

58
59
| Object analysis | |
| --- | --- |
Gael's avatar
Gael committed
60
61
62
63
64
65
66
67
68
| **fun_check()** | check class, type, length, etc., of objects |
| **fun_secu()** | verif that local variables are not present in other envs |
| **fun_info()** | recover object information |
| **fun_head()** | head of the left or right of big 2D objects |
| **fun_tail()** | tail of the left or right of big 2D objects |
| **fun_comp_1d()** | comparison of two 1D datasets (vectors, factors, 1D tables) |
| **fun_comp_2d()** | comparison of two 2D datasets (row & col names, dimensions, etc.) |
| **fun_comp_list()** | comparison of two lists |
| **fun_test()** | test combinations of argument values of a function and return errors (and graphs) |
Gael  MILLOT's avatar
Gael MILLOT committed
69

70
71
| Object modification | |
| --- | --- |
Gael's avatar
Gael committed
72
73
74
75
76
77
78
79
80
81
| **fun_name_change()** | check a vector of character strings and modify any string if present in another vector |
| **fun_df_remod()** | remodeling a data frame to have column name as a qualitative values and vice-versa |
| **fun_round()** | rounding number if decimal present |
| **fun_mat_rotate()** | 90° clockwise matrix rotation |
| **fun_mat_num2color()** | convert a numeric matrix into hexadecimal color matrix |
| **fun_mat_op()** | assemble several matrices with operation |
| **fun_mat_inv()** | return the inverse of a square matrix |
| **fun_mat_fill()** | fill the empty half part of a symmetric square matrix |
| **fun_permut()** | progressively breaks a vector order |
| **fun_slide()** | return a computation made on a vector using a sliding window |
Gael  MILLOT's avatar
Gael MILLOT committed
82

83
84
| Graphics management | |
| --- | --- |
Gael's avatar
Gael committed
85
86
87
88
89
90
91
| **fun_width()** | window width depending on classes to plot |
| **fun_open()** | open a GUI or pdf graphic window |
| **fun_prior_plot()** | set graph param before plotting (erase axes for instance) |
| **fun_scale()** | select nice label numbers when setting number of ticks on an axis |
| **fun_inter_ticks()** | define coordinates of secondary ticks |
| **fun_post_plot()** | set graph param after plotting (axes redesign for instance) |
| **fun_close()** | close specific graphic windows |
Gael  MILLOT's avatar
Gael MILLOT committed
92

93
94
| Standard graphics | |
| --- | --- |
Gael's avatar
Gael committed
95
| **fun_empty_graph()** | text to display for empty graphs |
Gael  MILLOT's avatar
Gael MILLOT committed
96

97
98
| gg graphics | |
| --- | --- |
Gael's avatar
Gael committed
99
100
101
102
103
104
105
| **fun_gg_palette()** | ggplot2 default color palette |
| **fun_gg_just()** | ggplot2 justification of the axis labeling, depending on angle |
| **fun_gg_get_legend()** | get the legend of ggplot objects |
| **fun_gg_point_rast()** | ggplot2 raster scatterplot layer |
| **fun_gg_boxplot()** | ggplot2 boxplot + background dots if required |
| **fun_gg_scatter()** | ggplot2 scatterplot + lines (up to 6 overlays totally) |
| **fun_gg_empty_graph()** | text to display for empty graphs |
Gael  MILLOT's avatar
Gael MILLOT committed
106

107
108
| Graphic extraction | |
| --- | --- |
Gael's avatar
Gael committed
109
110
| **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 |
Gael  MILLOT's avatar
Gael MILLOT committed
111

112
113
| Import | |
| --- | --- |
Gael's avatar
Gael committed
114
115
| **fun_pack()** | check if R packages are present and import into the working environment |
| **fun_python_pack()** | check if python packages are present |
Gael  MILLOT's avatar
Gael MILLOT committed
116

117
118
| Print / Exporting results (text & tables) | |
| --- | --- |
Gael's avatar
Gael committed
119
120
| **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) |
Gael  MILLOT's avatar
Gael MILLOT committed
121
122


123
## HOW TO LOAD AND MANIPULATE cute_little_R_functions
Gael  MILLOT's avatar
Gael MILLOT committed
124
125


126
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
127

Gael's avatar
Gael committed
128
For that:
Gael  MILLOT's avatar
Gael MILLOT committed
129

Gael's avatar
Gael committed
130
1) Select the desired tagged release
Gael  MILLOT's avatar
Gael MILLOT committed
131

Gael's avatar
Gael committed
132
133
134
135
136
137
138
2) Browse files

3) Display the cute_little_R_functions.R as raw file

4) Source the file using the url address. Example:

`source("https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/557976d693e37b499b89c76e4b2142846eb89d5b/cute_little_R_functions.R")`
Gael  MILLOT's avatar
Gael MILLOT committed
139

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

Gael's avatar
Gael committed
142
143
144
1) Either read the cute_little_functions.docx (or open the cute_little_R_functions.R file).

2) Or in the R/RStudio console, type the name of the function without brackets. Example : `fun_info`.
Gael  MILLOT's avatar
Gael MILLOT committed
145
146


147
## VERSIONS
Gael  MILLOT's avatar
Gael MILLOT committed
148

149
The different releases are tagged [here](https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/tags)
Gael  MILLOT's avatar
Gael MILLOT committed
150

Gael  MILLOT's avatar
Gael MILLOT committed
151

152
## LICENCE
Gael  MILLOT's avatar
Gael MILLOT committed
153

154
155
156
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.
Gael  MILLOT's avatar
Gael MILLOT committed
157

Gael  MILLOT's avatar
Gael MILLOT committed
158

159
## CITATION
Gael  MILLOT's avatar
Gael MILLOT committed
160

161
Not yet published
Gael  MILLOT's avatar
Gael MILLOT committed
162
163


164
## CREDITS
Gael  MILLOT's avatar
Gael MILLOT committed
165

166
[Gael A. Millot](https://gitlab.pasteur.fr/gmillot), Hub-CBD, Institut Pasteur, USR 3756 IP CNRS, Paris, France
Gael  MILLOT's avatar
Gael MILLOT committed
167
168


169
## ACKNOWLEDGEMENTS
Gael  MILLOT's avatar
Gael MILLOT committed
170

171
R and R packages developers
Gael  MILLOT's avatar
Gael MILLOT committed
172

173
174
175
176
177
178
Gitlab developers


## WHAT'S NEW IN

### v6.0.0
Gael  MILLOT's avatar
Gael MILLOT committed
179
180

1) name of functions changed:
181

Gael  MILLOT's avatar
Gael MILLOT committed
182
fun_param_check()	fun_check()
183

Gael  MILLOT's avatar
Gael MILLOT committed
184
fun_object_info()	fun_info()
185

Gael  MILLOT's avatar
saving    
Gael MILLOT committed
186
fun_1D_comp()	fun_comp_1d()
187

Gael  MILLOT's avatar
saving    
Gael MILLOT committed
188
fun_2D_comp()	fun_comp_2d()
189

Gael  MILLOT's avatar
saving    
Gael MILLOT committed
190
fun_list_comp()	fun_comp_list()
191

Gael  MILLOT's avatar
saving    
Gael MILLOT committed
192
fun_2D_head()	fun_head()
193

Gael  MILLOT's avatar
saving    
Gael MILLOT committed
194
fun_2D_tail()	fun_tail()
195

Gael  MILLOT's avatar
Gael MILLOT committed
196
fun_dataframe_remodeling()	fun_df_remod()
197

Gael  MILLOT's avatar
Gael MILLOT committed
198
fun_by_case_matrix_op()	fun_mat_op()
199

Gael  MILLOT's avatar
Gael MILLOT committed
200
fun_rounding()	fun_round()
201

202
fun_90clock_matrix_rot()	fun_mat_rotate()
203

204
fun_hexa_hsv_color_matrix()	fun_mat_num2color()
205

Gael  MILLOT's avatar
Gael MILLOT committed
206
fun_graph_param_prior_plot()	fun_prior_plot()
207

Gael  MILLOT's avatar
Gael MILLOT committed
208
fun_feature_post_plot()	fun_post_plot()
209

Gael  MILLOT's avatar
Gael MILLOT committed
210
fun_window_width_resizing()	fun_width()
211

Gael  MILLOT's avatar
Gael MILLOT committed
212
fun_open_window()	fun_open()
213

Gael  MILLOT's avatar
Gael MILLOT committed
214
fun_close_specif_window()	fun_close()
215

Gael  MILLOT's avatar
Gael MILLOT committed
216
fun_var_trim_display()	fun_trim()
217

Gael  MILLOT's avatar
Gael MILLOT committed
218
fun_export_data()	fun_report()
Gael  MILLOT's avatar
Gael MILLOT committed
219

220
221


Gael  MILLOT's avatar
Gael MILLOT committed
222
2) new functions added:
223

Gael  MILLOT's avatar
Gael MILLOT committed
224
fun_name_change()
225

Gael  MILLOT's avatar
Gael MILLOT committed
226
fun_mat_fill()
227

228
fun_permut()
229

Gael  MILLOT's avatar
Gael MILLOT committed
230
fun_permut_consec()
231

Gael  MILLOT's avatar
Gael MILLOT committed
232
fun_empty_graph()
233

Gael  MILLOT's avatar
Gael MILLOT committed
234
fun_gg_palette()
235

Gael  MILLOT's avatar
Gael MILLOT committed
236
fun_gg_just()
237

Gael  MILLOT's avatar
saving    
Gael MILLOT committed
238
fun_gg_point_rast()
239

Gael  MILLOT's avatar
Gael MILLOT committed
240
fun_gg_scatter()
241

Gael  MILLOT's avatar
Gael MILLOT committed
242
fun_gg_empty_graph()
243

Gael  MILLOT's avatar
Gael MILLOT committed
244
fun_segmentation()
245

Gael  MILLOT's avatar
Gael MILLOT committed
246
fun_pack()
247

Gael  MILLOT's avatar
Gael MILLOT committed
248
fun_python_pack()
249

Gael  MILLOT's avatar
Gael MILLOT committed
250
fun_warning()
Gael  MILLOT's avatar
Gael MILLOT committed
251

252
253


Gael  MILLOT's avatar
saving    
Gael MILLOT committed
254
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
255
256
257

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

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

Gael  MILLOT's avatar
Gael MILLOT committed
260
261
262
6) Functions checked for R version 3.6.1

7) function deprecated:
263

Gael  MILLOT's avatar
Gael MILLOT committed
264
fun_refactorization()
Gael  MILLOT's avatar
Gael MILLOT committed
265
266


267
### v5.1.0
Gael  MILLOT's avatar
Gael MILLOT committed
268
269
270
271

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


272
### v5.0.0
Gael  MILLOT's avatar
Gael MILLOT committed
273
274

1) fun_2D_head() function added
275

Gael  MILLOT's avatar
Gael MILLOT committed
276
2) fun_2D_tail() function added
277

Gael  MILLOT's avatar
Gael MILLOT committed
278
279
280
3) argument "noquote" added in fun_export_data()


281
### v4.9.0
Gael  MILLOT's avatar
Gael MILLOT committed
282
283
284
285

1) fun_mat_inv() function added


286
### v4.8.0
Gael  MILLOT's avatar
Gael MILLOT committed
287
288
289
290

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


291
### v4.7.0
Gael  MILLOT's avatar
Gael MILLOT committed
292
293
294
295

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


296
### v4.6.0
Gael  MILLOT's avatar
Gael MILLOT committed
297
298
299
300

1) fun_by_case_matrix_op() added


301
### v4.5.0
Gael  MILLOT's avatar
Gael MILLOT committed
302
303
304
305
306
307

1) fun_open_window() improved to deal with Linux systems

2) fun_graph_param_prior_plot() improved to deal with Linux systems


308
### v4.4.0
Gael  MILLOT's avatar
Gael MILLOT committed
309
310
311
312

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)


313
### v4.3.0
Gael  MILLOT's avatar
Gael MILLOT committed
314
315
316
317

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


318
### v4.2.0
Gael  MILLOT's avatar
Gael MILLOT committed
319
320
321
322

1) bug in the fun_2D_comp() function fixed


323
### v4.1.0
Gael  MILLOT's avatar
Gael MILLOT committed
324
325
326
327

1) text.corner replaced by corner.text everywhere


328
### v4.0.0
Gael  MILLOT's avatar
Gael MILLOT committed
329
330
331
332
333
334
335
336
337
338

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 


339
### v3.1.0
Gael  MILLOT's avatar
Gael MILLOT committed
340
341
342
343
344
345

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


346
### v3.0.0
Gael  MILLOT's avatar
Gael MILLOT committed
347

Gael  MILLOT's avatar
Gael MILLOT committed
348
1) cute_little_functions.R renamed cute_little_R_functions.R
Gael  MILLOT's avatar
Gael MILLOT committed
349

Gael  MILLOT's avatar
Gael MILLOT committed
350
351
2) function fun_dataframe_flipping() has been renamed fun_dataframe_remodeling()

Gael  MILLOT's avatar
Gael MILLOT committed
352
3) more examples added, also draws added in the .docx file for fun_dataframe_remodeling()
Gael  MILLOT's avatar
Gael MILLOT committed
353
354


355
### v2.0.1
Gael  MILLOT's avatar
Gael MILLOT committed
356
357
358
359

1) functions that use other functions from this toolset now check if these required functions are indeed present in the R environment


360
### v2.0.0
Gael  MILLOT's avatar
Gael MILLOT committed
361
362
363
364
365
366
367
368

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


369
370
### v1.3

Gael  MILLOT's avatar
Gael MILLOT committed
371
1) fun_1D_comp() function improved: provide the common elements, common names and common levels if exist
Gael  MILLOT's avatar
Gael MILLOT committed
372
373


Gael's avatar
Gael committed
374
375
376
### v1

Everything