diff --git a/cute_little_R_functions.R b/cute_little_R_functions.R index fa0bcd327195991bf21966b51d6ecd97de590d9e..329a40dae27e6abc751bdfca7791c1b13e86fb75 100644 --- a/cute_little_R_functions.R +++ b/cute_little_R_functions.R @@ -34,53 +34,53 @@ ################ Object analysis 2 ######## fun_check() #### check class, type, length, etc., of objects 2 -######## fun_secu() #### verif that local variables are not present in other envs 10 -######## fun_info() #### recover object information 12 -######## fun_head() #### head of the left or right of big 2D objects 14 -######## fun_tail() #### tail of the left or right of big 2D objects 15 -######## fun_comp_1d() #### comparison of two 1D datasets (vectors, factors, 1D tables) 16 -######## fun_comp_2d() #### comparison of two 2D datasets (row & col names, dimensions, etc.) 20 -######## fun_comp_list() #### comparison of two lists 26 -######## fun_test() #### test combinations of argument values of a function and return errors (and graphs) 29 -################ Object modification 43 -######## fun_name_change() #### check a vector of character strings and modify any string if present in another vector 43 -######## fun_df_remod() #### remodeling a data frame to have column name as a qualitative values and vice-versa 45 -######## fun_round() #### rounding number if decimal present 47 -######## fun_mat_rotate() #### 90° clockwise matrix rotation 49 -######## fun_mat_num2color() #### convert a numeric matrix into hexadecimal color matrix 50 -######## fun_mat_op() #### assemble several matrices with operation 53 -######## fun_mat_inv() #### return the inverse of a square matrix 56 -######## fun_mat_fill() #### fill the empty half part of a symmetric square matrix 57 -######## fun_permut() #### progressively breaks a vector order 61 -######## fun_slide() #### return a computation made on a vector using a sliding window 71 -################ Graphics management 78 -######## fun_width() #### window width depending on classes to plot 78 -######## fun_open() #### open a GUI or pdf graphic window 80 -######## fun_prior_plot() #### set graph param before plotting (erase axes for instance) 84 -######## fun_scale() #### select nice label numbers when setting number of ticks on an axis 88 -######## fun_inter_ticks() #### define coordinates of secondary ticks 93 -######## fun_post_plot() #### set graph param after plotting (axes redesign for instance) 97 -######## fun_close() #### close specific graphic windows 108 -################ Standard graphics 110 -######## fun_empty_graph() #### text to display for empty graphs 110 -################ gg graphics 112 -######## fun_gg_palette() #### ggplot2 default color palette 112 -######## fun_gg_just() #### ggplot2 justification of the axis labeling, depending on angle 113 -######## fun_gg_get_legend() #### get the legend of ggplot objects 116 -######## fun_gg_point_rast() #### ggplot2 raster scatterplot layer 118 -######## fun_gg_boxplot() #### ggplot2 boxplot + background dots if required 121 -######## fun_gg_scatter() #### ggplot2 scatterplot + lines (up to 6 overlays totally) 121 -######## fun_gg_heatmap() #### ggplot2 heatmap + overlaid mask if required 122 -######## fun_gg_empty_graph() #### text to display for empty graphs 135 -################ Graphic extraction 137 -######## fun_trim() #### display values from a quantitative variable and trim according to defined cut-offs 137 -######## fun_segmentation() #### segment a dot cloud on a scatterplot and define the dots from another cloud outside the segmentation 146 -################ Import 178 -######## fun_pack() #### check if R packages are present and import into the working environment 178 -######## fun_python_pack() #### check if python packages are present 180 -################ Print / Exporting results (text & tables) 182 -######## fun_report() #### print string or data object into output file 182 -######## fun_get_message() #### return error/warning/other messages of an expression (that can be exported) 185 +######## fun_secu() #### verif that local variables are not present in other envs 11 +######## fun_info() #### recover object information 13 +######## fun_head() #### head of the left or right of big 2D objects 15 +######## fun_tail() #### tail of the left or right of big 2D objects 16 +######## fun_comp_1d() #### comparison of two 1D datasets (vectors, factors, 1D tables) 17 +######## fun_comp_2d() #### comparison of two 2D datasets (row & col names, dimensions, etc.) 21 +######## fun_comp_list() #### comparison of two lists 29 +######## fun_test() #### test combinations of argument values of a function and return errors (and graphs) 31 +################ Object modification 46 +######## fun_name_change() #### check a vector of character strings and modify any string if present in another vector 46 +######## fun_df_remod() #### remodeling a data frame to have column name as a qualitative values and vice-versa 47 +######## fun_round() #### rounding number if decimal present 50 +######## fun_mat_rotate() #### 90° clockwise matrix rotation 52 +######## fun_mat_num2color() #### convert a numeric matrix into hexadecimal color matrix 53 +######## fun_mat_op() #### assemble several matrices with operation 56 +######## fun_mat_inv() #### return the inverse of a square matrix 59 +######## fun_mat_fill() #### fill the empty half part of a symmetric square matrix 60 +######## fun_permut() #### progressively breaks a vector order 64 +######## fun_slide() #### return a computation made on a vector using a sliding window 75 +################ Graphics management 83 +######## fun_width() #### window width depending on classes to plot 83 +######## fun_open() #### open a GUI or pdf graphic window 85 +######## fun_prior_plot() #### set graph param before plotting (erase axes for instance) 89 +######## fun_scale() #### select nice label numbers when setting number of ticks on an axis 93 +######## fun_inter_ticks() #### define coordinates of secondary ticks 98 +######## fun_post_plot() #### set graph param after plotting (axes redesign for instance) 102 +######## fun_close() #### close specific graphic windows 114 +################ Standard graphics 116 +######## fun_empty_graph() #### text to display for empty graphs 116 +################ gg graphics 117 +######## fun_gg_palette() #### ggplot2 default color palette 117 +######## fun_gg_just() #### ggplot2 justification of the axis labeling, depending on angle 119 +######## fun_gg_get_legend() #### get the legend of ggplot objects 124 +######## fun_gg_point_rast() #### ggplot2 raster scatterplot layer 126 +######## fun_gg_boxplot() #### ggplot2 boxplot + background dots if required 129 +######## fun_gg_scatter() #### ggplot2 scatterplot + lines (up to 6 overlays totally) 129 +######## fun_gg_heatmap() #### ggplot2 heatmap + overlaid mask if required 130 +######## fun_gg_empty_graph() #### text to display for empty graphs 143 +################ Graphic extraction 145 +######## fun_trim() #### display values from a quantitative variable and trim according to defined cut-offs 145 +######## fun_segmentation() #### segment a dot cloud on a scatterplot and define the dots from another cloud outside the segmentation 154 +################ Import 188 +######## fun_pack() #### check if R packages are present and import into the working environment 188 +######## fun_python_pack() #### check if python packages are present 190 +################ Print / Exporting results (text & tables) 193 +######## fun_report() #### print string or data object into output file 193 +######## fun_get_message() #### return error/warning/other messages of an expression (that can be exported) 196 ################################ FUNCTIONS ################################ @@ -6058,7 +6058,7 @@ stop(paste0("\n\n================\n\n", tempo.cat, "\n\n================\n\n"), } # end argument checking # main code -if(class(data)%in% c("matrix", "array")){ +if(all(class(data)%in% c("matrix", "array"))){ data <- as.vector(data) } na.nb <- NULL @@ -7966,9 +7966,9 @@ return(output) # do not use cat() because the idea is to reuse the message -# check s/lapply everywhere with get: done cute boxplot scatter -# get() with env everywhere: done cute boxplot scatter -# add the new NA and NULL check cute, boxplot, scatter: done boxplot, scatter +# check s/lapply everywhere with get: done cute boxplot scatter anova comat +# get() with env everywhere: done cute boxplot scatter anova comat +# add the new NA and NULL check cute, done for all the rest fun_gg_boxplot <- function( data1, diff --git a/cute_little_R_functions.docx b/cute_little_R_functions.docx index f172a4cbf485949b96e420779e0e592fdababd3b..7e252b31bad667024d705a841cbfc2a788144aeb 100644 Binary files a/cute_little_R_functions.docx and b/cute_little_R_functions.docx differ diff --git a/fun_gg_boxplot.docx b/fun_gg_boxplot.docx index fa25d301a30f1a5b17a30eed6d7dc033a048064b..e37390c911c0202540b90ca313ce59d006ee0409 100644 Binary files a/fun_gg_boxplot.docx and b/fun_gg_boxplot.docx differ