Commit 3f25c8ff authored by Gael's avatar Gael
Browse files

reorganization

parent 1553bf22
################ CREATION OF THE CHECKING DATASET
######## object list t25_20201108 (25 objects created 20201108)
vec1 <- -1:3 # vector of integers
vec2 <- 1:3 / 3 # vector of proportions
vec3 <- c(1, 2, NA, -Inf) # vector of integers but stored as "double", with NA and Inf
vec4 <- "pearson" # vector of characters
vec5 <- c("a", "b","a", NA) # vector of characters with NA
cpx1 <- as.complex(1) # complex
mat1 <- matrix(vec1) # 1D matrix of integers
mat2 <- matrix(c(1:5, NA), ncol = 2, dimnames = list(c("ROW1", "ROW2", "ROW3"), c("M1", "M2"))) # 2D matrix of floats with NA
df1 <- as.data.frame(mat2) # data.frame
l1 <- list(L1 = 1:3, L2 = letters[1:3]) # list
fac1 <- factor(rep(letters[4:6], c(4:6))) # factor
tab1 <- table(fac1) # 1D table
tab2 <- table(fac1, fac1) # 2D table
exp1 <- expression("a") # object of class "expression", mode "expression" & type "expression"
name1 <- substitute(exp1) # object of class "name", mode "name" & type "symbol"
fun1 <- mean # closure function of class "function", mode "function" & type "closure"
fun2 <- sum # primitive function of class "function", mode "function" & type "builtin"
fun3 <- get("<-") # primitive function of class "function", mode "function" & type "special"
env1 <- new.env() # environment
s4.1 <- show # S4 object
call1 <- call("call1") # object of class "call", mode "call" & type "language"
t25_20201108 <- list( # test list
NULL,
NA,
1,
TRUE,
vec1,
vec2,
vec3,
vec4,
vec5,
cpx1,
mat1,
mat2,
df1,
l1,
fac1,
tab1,
tab2,
exp1,
name1,
fun1,
fun2,
fun3,
env1,
s4.1,
call1
)
save(list = c(
"vec1",
"vec2",
"vec3",
"vec4",
"vec5",
"cpx1",
"mat1",
"mat2",
"df1",
"l1",
"fac1",
"tab1",
"tab2",
"exp1",
"name1",
"fun1",
"fun2",
"fun3",
"env1",
"s4.1",
"call1",
"t25_20201108"
), file = "C:/Users/gael/Documents/Git_projects/cute_little_R_functions/check/check_dataset.t25_20201108.RData")
######## object list t26_20201124 (26 objects created 20201124)
vec1 <- -1:3 # vector of integers
vec2 <- 1:3 / 3 # vector of proportions
vec3 <- c(1, 2, NA, -Inf) # vector of integers but stored as "double", with NA and Inf
vec4 <- "pearson" # vector of characters
vec5 <- c("a", "b","a", NA) # vector of characters with NA
cpx1 <- as.complex(1) # complex
mat1 <- matrix(vec1) # 1D matrix of integers
mat2 <- matrix(c(1:5, NA), ncol = 2, dimnames = list(c("ROW1", "ROW2", "ROW3"), c("M1", "M2"))) # 2D matrix of floats with NA
df1 <- as.data.frame(mat2) # data.frame
df2 <- data.frame(df1, CAT = letters[1:nrow(df1)]) # data.frame
l1 <- list(L1 = 1:3, L2 = letters[1:3]) # list
fac1 <- factor(rep(letters[4:6], c(4:6))) # factor
tab1 <- table(fac1) # 1D table
tab2 <- table(fac1, fac1) # 2D table
exp1 <- expression("a") # object of class "expression", mode "expression" & type "expression"
name1 <- substitute(exp1) # object of class "name", mode "name" & type "symbol"
fun1 <- mean # closure function of class "function", mode "function" & type "closure"
fun2 <- sum # primitive function of class "function", mode "function" & type "builtin"
fun3 <- get("<-") # primitive function of class "function", mode "function" & type "special"
env1 <- new.env() # environment
s4.1 <- show # S4 object
call1 <- call("call1") # object of class "call", mode "call" & type "language"
t26_20201124 <- list( # test list
NULL,
NA,
1,
TRUE,
vec1,
vec2,
vec3,
vec4,
vec5,
cpx1,
mat1,
mat2,
df1,
df2,
l1,
fac1,
tab1,
tab2,
exp1,
name1,
fun1,
fun2,
fun3,
env1,
s4.1,
call1
)
save(list = c(
"vec1",
"vec2",
"vec3",
"vec4",
"vec5",
"cpx1",
"mat1",
"mat2",
"df1",
"df2",
"l1",
"fac1",
"tab1",
"tab2",
"exp1",
"name1",
"fun1",
"fun2",
"fun3",
"env1",
"s4.1",
"call1",
"t26_20201124"
), file = "C:/Users/gael/Documents/Git_projects/cute_little_R_functions/check/check_dataset.t26_20201124.RData")
######## object list t8_20201126 (8 objects created 20201126)
cor1 <- list(-1, 0, 1) # vector of integers
prop1 <- list(0, 0.5, 1) # vector of proportions
int1 <- list(0, 2, 4) # vector of positive integers
int2 <- list(0, 10, 20) # vector of positive integers
angle1 <- list(-90, 0, 45, 90, 180) # vector of positive integers
log1 <- list("no", "log2", "log10") # vector of characters
logic1 <- list(TRUE, FALSE) # vector of logic
path1 <- list("C:\\Program Files\\R\\R-4.0.2\\library\\")
t8_20201126 <- list( # test list
cor1,
prop1,
int1,
int2,
angle1,
log1,
logic1,
path1
)
save(list = c(
"cor1",
"prop1",
"int1",
"int2",
"angle1",
"log1",
"logic1",
"path1",
"t8_20201126"
), file = "C:/Users/gael/Documents/Git_projects/cute_little_R_functions/check/check_dataset.t8_20201126.RData")
################ END CREATION OF THE CHECKING DATASET
######## fun_check() #### check class, type, length, etc., of objects
# 20201216 checking each argument separately, with default values for the others
load("C:/Users/gael/Documents/Git_projects/cute_little_R_functions/other/check_dataset.t26_20201124.RData") # recover the test list tl file
source("https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/7ceacbc07ba1cc65b3dd8db53ef0d8db2a2823d7/cute_little_R_functions.R")
# performed with check_dataset.RData commited 20201107 (25 different objects)
# in green the values that are not the default values
path <- "C:\\Users\\Gael\\Desktop\\fun_check_test1\\"
for(i0 in 1:14){
Sys.sleep(1)
cat("\n\nLOOP ", i0, " / 14\n\n")
res <- fun_test(
fun = "fun_check",
arg = c(
L1 = "data",
L2 = "class",
L3 = "typeof",
L4 = "mode",
L5 = "length",
L6 = "prop",
L7 = "double.as.integer.allowed",
L8 = "options",
L9 = "all.options.in.data",
L10 = "na.contain",
L11 = "neg.values",
L12 = "print",
L13 = "data.name",
L14 = "fun.name"
),
val = list(
L1 = if(i0 == 1){t26_20201124}else{"a"},
L2 = if(i0 == 2){t26_20201124}else{"vector"},
L3 = if(i0 == 3){t26_20201124}else{list(NULL)},
L4 = if(i0 == 4){t26_20201124}else{list(NULL)},
L5 = if(i0 == 5){t26_20201124}else{list(NULL)},
L6 = if(i0 == 6){t26_20201124}else{FALSE},
L7 = if(i0 == 7){t26_20201124}else{FALSE},
L8 = if(i0 == 8){t26_20201124}else{list(NULL)},
L9 = if(i0 == 9){t26_20201124}else{FALSE},
L10 = if(i0 == 10){t26_20201124}else{FALSE},
L11 = if(i0 == 11){t26_20201124}else{TRUE},
L12 = if(i0 == 12){t26_20201124}else{FALSE},
L13 = if(i0 == 13){t26_20201124}else{"test.function"},
L14 = if(i0 == 14){t26_20201124}else{list(NULL)}
),
thread.nb = NULL,
plot.fun = FALSE,
export = TRUE,
res.path = path
)
}
file.list <- list.files(path, full.names = TRUE)
tempo.df <- NULL
for(i0 in 1:length(file.list)){
tempo.df <- rbind(tempo.df, cbind(loop = paste0("loop_", i0), read.table(list.files(file.list[i0], , full.names = TRUE)[grepl(x = list.files(file.list[i0]), pattern = "^table_from_fun_test.*")], header = TRUE, sep = "\t", comment.char="")))
}
write.table(tempo.df, file = paste0(path, "/final_table_from_fun_test.txt"), row.names = FALSE, col.names = TRUE, append = FALSE, quote = FALSE, sep = "\t", eol = "\n", na = "")
# 20201216 checking all the possible values of each argument, with default values for the others
load("C:/Users/gael/Documents/Git_projects/cute_little_R_functions/other/check_dataset.t26_20201124.RData") # recover the test list tl file
load("C:/Users/gael/Documents/Git_projects/cute_little_R_functions/other/check_dataset.t8_20201126.RData") # recover the test list tl file
source("https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/7ceacbc07ba1cc65b3dd8db53ef0d8db2a2823d7/cute_little_R_functions.R")
# performed with check_dataset.RData commited 20201107 (25 different objects)
# in green the values that are not the default values
path <- "C:\\Users\\Gael\\Desktop\\fun_check_test2\\"
for(i0 in 1:14){
Sys.sleep(1)
cat("\n\nLOOP ", i0, " / 14\n\n")
res <- fun_test(
fun = "fun_check",
arg = c(
L1 = "data",
L2 = "class",
L3 = "typeof",
L4 = "mode",
L5 = "length",
L6 = "prop",
L7 = "double.as.integer.allowed",
L8 = "options",
L9 = "all.options.in.data",
L10 = "na.contain",
L11 = "neg.values",
L12 = "print",
L13 = "data.name",
L14 = "fun.name"
),
val = list(
L1 = if(i0 == 1){t26_20201124}else{"a"},
L2 = if(i0 == 2){list(NULL, "vector", "logical", "integer", "numeric", "complex", "character", "matrix", "array", "data.frame", "list", "factor", "table", "expression", "name", "symbol", "function", "uneval", "environment", "ggplot2", "ggplot_built", "call")}else if(i0 == 8){list(NULL)}else{"vector"},
L3 = if(i0 == 3){list(NULL, "logical", "integer", "double", "complex", "character", "list", "expression", "symbol", "closure", "special", "builtin", "environment", "S4", "language")}else{list(NULL)},
L4 = if(i0 == 4){list(NULL, "logical", "numeric", "complex", "character", "list", "expression", "name", "symbol", "function", "environment", "S4", "call")}else{list(NULL)},
L5 = if(i0 == 5){list(NULL, 0, 2, 4)}else{list(NULL)},
L6 = if(i0 == 6){logic1}else{FALSE},
L7 = if(i0 == 7){logic1}else{FALSE},
L8 = if(i0 == 8){list(NULL, "a")}else{list(NULL)},
L9 = if(i0 == 9){logic1}else{FALSE},
L10 = if(i0 == 10){logic1}else{FALSE},
L11 = if(i0 == 11){logic1}else{TRUE},
L12 = if(i0 == 12){logic1}else{TRUE},
L13 = if(i0 == 13){list(NULL, "test.function")}else{list(NULL)},
L14 = if(i0 == 14){list(NULL, "FUN_NAME")}else{list(NULL)}
),
thread.nb = NULL,
plot.fun = FALSE,
export = TRUE,
res.path = path
)
}
file.list <- list.files(path, full.names = TRUE)
tempo.df <- NULL
for(i0 in 1:length(file.list)){
tempo.df <- rbind(tempo.df, cbind(loop = paste0("loop_", i0), read.table(list.files(file.list[i0], , full.names = TRUE)[grepl(x = list.files(file.list[i0]), pattern = "^table_from_fun_test.*")], header = TRUE, sep = "\t", comment.char="")))
}
write.table(tempo.df, file = paste0(path, "/final_table_from_fun_test.txt"), row.names = FALSE, col.names = TRUE, append = FALSE, quote = FALSE, sep = "\t", eol = "\n", na = "")
# 20201126 checking each argument separately, with default values for the others
load("C:/Users/gael/Documents/Git_projects/cute_little_R_functions/other/check_dataset.t26_20201124.RData") # recover the test list tl file
source("https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/7ceacbc07ba1cc65b3dd8db53ef0d8db2a2823d7/cute_little_R_functions.R")
# performed with check_dataset.RData commited 20201107 (25 different objects)
# in green the values that are not the default values
path <- "C:\\Users\\Gael\\Desktop\\fun_boxplot_test1\\"
for(i0 in 1:57){
Sys.sleep(1)
cat("\n\nLOOP ", i0, " / 57\n\n")
res <- fun_test(
fun = "fun_gg_boxplot",
arg = c(
L1 = "data1",
L2 = "y",
L3 = "categ",
L4 = "categ.class.order",
L5 = "categ.color",
L6 = "box.legend.name",
L7 = "box.fill",
L8 = "box.width",
L9 = "box.space",
L10 = "box.line.size",
L11 = "box.notch",
L12 = "box.alpha",
L13 = "box.mean",
L14 = "box.whisker.kind",
L15 = "box.whisker.width",
L16 = "dot.color",
L17 = "dot.categ",
L18 = "dot.categ.class.order",
L19 = "dot.legend.name",
L20 = "dot.tidy",
L21 = "dot.tidy.bin.nb",
L22 = "dot.jitter",
L23 = "dot.seed",
L24 = "dot.size",
L25 = "dot.alpha",
L26 = "dot.border.size",
L27 = "dot.border.color",
L28 = "x.lab",
L29 = "x.angle",
L30 = "y.lab",
L31 = "y.lim",
L32 = "y.log",
L33 = "y.tick.nb",
L34 = "y.second.tick.nb",
L35 = "y.include.zero",
L36 = "y.top.extra.margin",
L37 = "y.bottom.extra.margin",
L38 = "stat.disp",
L39 = "stat.disp.mean",
L40 = "stat.size",
L41 = "stat.dist",
L42 = "stat.angle",
L43 = "vertical",
L44 = "text.size",
L45 = "title",
L46 = "title.text.size",
L47 = "legend.show",
L48 = "legend.width",
L49 = "article",
L50 = "grid",
L51 = "add",
L52 = "return",
L53 = "return.ggplot",
L54 = "return.gtable",
L55 = "plot",
L56 = "warn.print",
L57 = "lib.path"
),
val = list(
L1 = if(i0 == 1){t26_20201124}else{list(df2)},
L2 = if(i0 == 2){t26_20201124}else{"M1"},
L3 = if(i0 == 3){t26_20201124}else{"CAT"},
L4 = if(i0 == 4){t26_20201124}else{list(NULL)},
L5 = if(i0 == 5){t26_20201124}else{list(NULL)},
L6 = if(i0 == 6){t26_20201124}else{list(NULL)},
L7 = if(i0 == 7){t26_20201124}else{FALSE},
L8 = if(i0 == 8){t26_20201124}else{0.5},
L9 = if(i0 == 9){t26_20201124}else{0.1},
L10 = if(i0 == 10){t26_20201124}else{0.75},
L11 = if(i0 == 11){t26_20201124}else{FALSE},
L12 = if(i0 == 12){t26_20201124}else{1},
L13 = if(i0 == 13){t26_20201124}else{TRUE},
L14 = if(i0 == 14){t26_20201124}else{"std"},
L15 = if(i0 == 15){t26_20201124}else{0},
L16 = if(i0 == 16){t26_20201124}else{grey(0.25)},
L17 = if(i0 == 17){t26_20201124}else{list(NULL)},
L18 = if(i0 == 18){t26_20201124}else{list(NULL)},
L19 = if(i0 == 19){t26_20201124}else{list(NULL)},
L20 = if(i0 == 20){t26_20201124}else{FALSE},
L21 = if(i0 == 21){t26_20201124}else{50},
L22 = if(i0 == 22){t26_20201124}else{0.5},
L23 = if(i0 == 23){t26_20201124}else{2},
L24 = if(i0 == 24){t26_20201124}else{3},
L25 = if(i0 == 25){t26_20201124}else{0.5},
L26 = if(i0 == 26){t26_20201124}else{0.5},
L27 = if(i0 == 27){t26_20201124}else{list(NULL)},
L28 = if(i0 == 28){t26_20201124}else{list(NULL)},
L29 = if(i0 == 29){t26_20201124}else{0},
L30 = if(i0 == 30){t26_20201124}else{list(NULL)},
L31 = if(i0 == 31){t26_20201124}else{list(NULL)},
L32 = if(i0 == 32){t26_20201124}else{"no"},
L33 = if(i0 == 33){t26_20201124}else{list(NULL)},
L34 = if(i0 == 34){t26_20201124}else{1},
L35 = if(i0 == 35){t26_20201124}else{FALSE},
L36 = if(i0 == 36){t26_20201124}else{0.05},
L37 = if(i0 == 37){t26_20201124}else{0.05},
L38 = if(i0 == 38){t26_20201124}else{"top"},
L39 = if(i0 == 39){t26_20201124}else{FALSE},
L40 = if(i0 == 40){t26_20201124}else{4},
L41 = if(i0 == 41){t26_20201124}else{5},
L42 = if(i0 == 42){t26_20201124}else{0},
L43 = if(i0 == 43){t26_20201124}else{TRUE},
L44 = if(i0 == 44){t26_20201124}else{12},
L45 = if(i0 == 45){t26_20201124}else{""},
L46 = if(i0 == 46){t26_20201124}else{8},
L47 = if(i0 == 47){t26_20201124}else{TRUE},
L48 = if(i0 == 48){t26_20201124}else{0.5},
L49 = if(i0 == 49){t26_20201124}else{TRUE},
L50 = if(i0 == 50){t26_20201124}else{FALSE},
L51 = if(i0 == 51){t26_20201124}else{list(NULL)},
L52 = if(i0 == 52){t26_20201124}else{FALSE},
L53 = if(i0 == 53){t26_20201124}else{FALSE},
L54 = if(i0 == 54){t26_20201124}else{TRUE},
L55 = if(i0 == 55){t26_20201124}else{TRUE},
L56 = if(i0 == 56){t26_20201124}else{TRUE},
L57 = if(i0 == 57){t26_20201124}else{list(NULL)}
),
thread.nb = NULL,
plot.fun = FALSE,
export = TRUE,
res.path = path
)
}
file.list <- list.files(path, full.names = TRUE)
tempo.df <- NULL
for(i0 in 1:length(file.list)){
tempo.df <- rbind(tempo.df, cbind(loop = paste0("loop_", i0), read.table(list.files(file.list[i0], full.names = TRUE)[grepl(x = list.files(file.list[i0]), pattern = "^table_from_fun_test.*")], header = TRUE, sep = "\t", comment.char="")))
}
write.table(tempo.df, file = paste0(path, "/final_table_from_fun_test.txt"), row.names = FALSE, col.names = TRUE, append = FALSE, quote = FALSE, sep = "\t", eol = "\n", na = "")
# 20201126 checking all the possible values of each argument, with default values for the others
load("C:/Users/gael/Documents/Git_projects/cute_little_R_functions/other/check_dataset.t8_20201126.RData") # recover the test list tl file
source("https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/7ceacbc07ba1cc65b3dd8db53ef0d8db2a2823d7/cute_little_R_functions.R")
# performed with check_dataset.RData commited 20201107 (25 different objects)
# in green the values that are not the default values
path <- "C:\\Users\\Gael\\Desktop\\fun_boxplot_test2\\"
### Data set
set.seed(1)
obs1 <- data.frame(
Time = c(rnorm(20, 100, 10), rnorm(20, 200, 50), rnorm(20, 500, 60), rep(NA, 20)),
Categ1 = rep(c("CAT", "DOG"), times = 40),
Categ2 = rep(c("A", "B", "C", "D"), each = 20),
Color1 = rep(c("coral", "lightblue"), times = 40),
Color2 = rep(c("#9F2108", "#306100", "#007479", "#8500C0"), each = 20),
stringsAsFactors = TRUE
)
set.seed(NULL)
### end Data set
for(i0 in 1:57){
Sys.sleep(1)
cat("\n\nLOOP ", i0, " / 57\n\n")
res <- fun_test(
fun = "fun_gg_boxplot",
arg = c(
L1 = "data1",
L2 = "y",
L3 = "categ",
L4 = "categ.class.order",
L5 = "categ.color",
L6 = "box.legend.name",
L7 = "box.fill",
L8 = "box.width",
L9 = "box.space",
L10 = "box.line.size",
L11 = "box.notch",
L12 = "box.alpha",
L13 = "box.mean",
L14 = "box.whisker.kind",
L15 = "box.whisker.width",
L16 = "dot.color",
L17 = "dot.categ",
L18 = "dot.categ.class.order",
L19 = "dot.legend.name",
L20 = "dot.tidy",
L21 = "dot.tidy.bin.nb",
L22 = "dot.jitter",
L23 = "dot.seed",
L24 = "dot.size",
L25 = "dot.alpha",
L26 = "dot.border.size",
L27 = "dot.border.color",
L28 = "x.lab",
L29 = "x.angle",
L30 = "y.lab",
L31 = "y.lim",
L32 = "y.log",
L33 = "y.tick.nb",
L34 = "y.second.tick.nb",
L35 = "y.include.zero",
L36 = "y.top.extra.margin",
L37 = "y.bottom.extra.margin",
L38 = "stat.disp",
L39 = "stat.disp.mean",
L40 = "stat.size",
L41 = "stat.dist",
L42 = "stat.angle",
L43 = "vertical",
L44 = "text.size",
L45 = "title",
L46 = "title.text.size",
L47 = "legend.show",
L48 = "legend.width",
L49 = "article",
L50 = "grid",
L51 = "add",
L52 = "return",
L53 = "return.ggplot",
L54 = "return.gtable",
L55 = "plot",
L56 = "warn.print",
L57 = "lib.path"
),
val = list(