# No result displayed because the output list is assigned into res (see below the print argument)
res<-fun_check(data=vec1,class="integer")
res
# with NULL, the function systematically report a checking problem
fun_check(data=NULL,class="integer")
### Argument class, typeof, mode and length are the same as the corresponding R function, except class which 1) has also "vector" and 2) remains "matrix" for matrices and not "matrix" "array"
# Example
fun_check(data=vec1,
class="vector",
typeof="integer",
mode="numeric",
length=5,
)
# Warning: the function does not check for inconsistencies between arguments. It just checks if everything is ok between arguments values and data
fun_check(data=vec1,
typeof="integer",
mode="character",# the mode "character" exists but is inconsistant with typeof "integer". However, this aspect is not signaled by the function
)
# Error message due to wrong value in the class and length arguments
fun_check(data=vec1,
mode="integer",# the mode "integer" does not exist in the mode() function of R
)
### Argument prop
fun_check(data=mat2,
prop=TRUE# Check for values between 0 and 1 only
)
### Argument double.as.integer.allowed
fun_check(data=vec3,typeof="integer",
double.as.integer.allowed=TRUE# with TRUE, integers stored as double are accepted
)
### Argument options
fun_check(data=vec4,
options=c("pearson","spearman","kendall")
)
### Argument all.options.in.data
# No error
fun_check(data=vec5,
options=c("a","b"),
all.options.in.data=TRUE
)
# No error
fun_check(data=vec5,
options=c("a","b","c"),
all.options.in.data=FALSE
)
# Error
fun_check(data=vec5,
options=c("a","b","c"),
all.options.in.data=TRUE
)
### Argument na.contain
fun_check(data=mat2,class="matrix",prop=TRUE,
na.contain=FALSE# with TRUE, integers stored as double are accepted
)
### Argument neg.values
# Warning: only considered if set to FALSE, to check for non negative values when class is set to "vector", "numeric", "matrix", "array", "data.frame", "table", or typeof is set to "double", "integer", or mode is set to "numeric"
fun_check(data=mat1,class="matrix",
neg.values=FALSE# with TRUE, integers stored as double are accepted
)
### Argument print
# No error message printed because print is FALSE
res<-fun_check(data=mat1,class="data.frame",
print=FALSE
)
# Error message printed
res<-fun_check(data=mat1,class="data.frame",
print=TRUE
)
# Even if print is TRUE, no error message printed because no error
res<-fun_check(data=mat1,class="matrix",
print=TRUE
)
### Arguments data.name and fun.name
# Example
tempo<-fun_check(data=vec1,class="integer",
data.name="OBSERVATION_1",
fun.name="FUNCTION_1"
)
tempo$text
# In fact, these two arguments are interesting when fun_check() is used inside functions
fun1<-function(arg1){
tempo<-fun_check(data=arg1,class="integer",
data.name=NULL,# if NULL, the name displayed is arg1