get_message
get_message.Rmd
library(saferDev)
Datasets
char1 <- "wilcox.test(c(1,1,3), c(1, 2, 4), paired = TRUE)" # single character string
char2 <- "message('ahah')" # single character string
Datasets info
char1 # single character string
> [1] "wilcox.test(c(1,1,3), c(1, 2, 4), paired = TRUE)"
char2 # single character string
> [1] "message('ahah')"
Argument kind
get_message(data = char1, kind = "warning") # to get warning messages of the wilcox test
> [1] "WARNING MESSAGE REPORTED:\nIn wilcox.test.default(c(1, 1, 3), c(1, 2, 4), paired = TRUE): cannot compute exact p-value with zeroes\n"
Argument header
get_message(data = char1, header = FALSE) # to get error messages (by default) without header
> NULL
Argument print_no
get_message(data = char1, print_no = TRUE) # print a message saying that no message reported
> [1] "NO ERROR MESSAGE REPORTED"
Argument text
get_message(
data = char2,
print_no = TRUE,
text = "IN A"
) # print a message even if the argument print_no is TRUE
> [1] "NO ERROR MESSAGE REPORTED IN A"
Argument kind, header, print_no, text
get_message(
data = char1,
kind = "warning",
header = FALSE,
print_no = TRUE,
text = "IN A"
) # print the warning message in text
> [1] "simpleWarning in wilcox.test.default(c(1, 1, 3), c(1, 2, 4), paired = TRUE): cannot compute exact p-value with zeroes\n"
Argument safer_check
get_message(data = char2, safer_check = TRUE) # with TRUE, checkings are performed before main code running
> NULL
Argument lib_path and error_text
get_message(
lib_path = ".", # absolute pathways of the directories containing the required packages if not in the default directories.
error_text = "TEXT ADDED" # add information in error messages returned by the function.
)
> Error:
>
> ================
>
> ERROR IN saferDev::get_message()TEXT ADDED
>
> FOLLOWING ARGUMENT HAS NO DEFAULT VALUE AND REQUIRE ONE:
> data
>
> ================
All the arguments
get_message(
data = char1,
kind = "warning",
header = FALSE,
print_no = TRUE,
text = "IN A",
env = NULL,
safer_check = TRUE, # perform some "safer" checks? Warning : always set this argument to FALSE if all_args_here() is used inside another safer function.
lib_path = NULL, # absolute pathways of the directories containing the required packages if not in the default directories.
error_text = "" # add information in error messages returned by the function.
) # print the warning message in text in the environment R_GlobalEnv
> [1] "simpleWarning in wilcox.test.default(c(1, 1, 3), c(1, 2, 4), paired = TRUE): cannot compute exact p-value with zeroes\n"