cute_little_R_functions.R 721 KB
Newer Older
Gael  MILLOT's avatar
Gael MILLOT committed
10001
}else{
Gael  MILLOT's avatar
Gael MILLOT committed
10002
tempo.warn <- paste(tempo.warn, collapse = "\n")
Gael  MILLOT's avatar
Gael MILLOT committed
10003
}
Gael  MILLOT's avatar
Gael MILLOT committed
10004
10005
10006
if(header == TRUE){
if(any(grepl(x = tempo.warn[[1]], pattern = "^simpleWarning i"))){
tempo.warn[[1]] <- gsub(x = tempo.warn[[1]], pattern = "^Warning i", replacement = "I")
Gael  MILLOT's avatar
Gael MILLOT committed
10007
}
Gael  MILLOT's avatar
Gael MILLOT committed
10008
10009
if(any(grepl(x = tempo.warn[[1]], pattern = "^Warning i"))){
tempo.warn[[1]] <- gsub(x = tempo.warn[[1]], pattern = "^Warning i", replacement = "I")
Gael  MILLOT's avatar
Gael MILLOT committed
10010
}
Gael  MILLOT's avatar
Gael MILLOT committed
10011
output <- paste0("WARNING MESSAGE REPORTED", ifelse(is.null(text), "", " "), text, ":\n", tempo.warn) #
Gael  MILLOT's avatar
Gael MILLOT committed
10012
}else{
Gael  MILLOT's avatar
Gael MILLOT committed
10013
output <- tempo.warn #
Gael  MILLOT's avatar
Gael MILLOT committed
10014
}
Gael  MILLOT's avatar
Gael MILLOT committed
10015
10016
}else if(print.no == TRUE){
output <- paste0("NO WARNING MESSAGE REPORTED", ifelse(is.null(text), "", " "), text)
Gael  MILLOT's avatar
Gael MILLOT committed
10017
}
Gael  MILLOT's avatar
Gael MILLOT committed
10018
10019
10020
10021
10022
10023
}else if(kind == "warning" & is.null(tempo.warn) & print.no == TRUE){
output <- paste0("NO WARNING MESSAGE REPORTED", ifelse(is.null(text), "", " "), text)
}else if(kind == "message" & exists("tempo.message", inherit = FALSE) == TRUE){ # inherit = FALSE avoid the portee lexical and thus the declared word
if(length(tempo.message) > 0){ # if something is returned by capture.ouptput() (only in this env) with a length more than 1
if(header == TRUE){
output <- paste0("STANDARD (NON ERROR AND NON WARNING) MESSAGE REPORTED", ifelse(is.null(text), "", " "), text, ":\n", tempo.message) #
Gael  MILLOT's avatar
Gael MILLOT committed
10024
}else{
Gael  MILLOT's avatar
Gael MILLOT committed
10025
output <- tempo.message #
Gael  MILLOT's avatar
Gael MILLOT committed
10026
}
Gael  MILLOT's avatar
Gael MILLOT committed
10027
10028
}else if(print.no == TRUE){
output <- paste0("NO STANDARD (NON ERROR AND NON WARNING) MESSAGE REPORTED", ifelse(is.null(text), "", " "), text)
Gael  MILLOT's avatar
Gael MILLOT committed
10029
}
Gael  MILLOT's avatar
Gael MILLOT committed
10030
10031
10032
10033
10034
10035
}else if(kind == "message" & exists("tempo.message", inherit = FALSE) == FALSE & print.no == TRUE){
output <- paste0("NO STANDARD (NON ERROR AND NON WARNING) MESSAGE REPORTED", ifelse(is.null(text), "", " "), text)
}
}
invisible(dev.off(window.nb)) # end send plots into a NULL file
return(output) # do not use cat() because the idea is to reuse the message
Gael  MILLOT's avatar
Gael MILLOT committed
10036
10037
}

10038
10039