[Rd] R: determine if `suppressMessages()` has been invoked

2023-02-19 Thread Nino Hardt
Hi all, I would like to create a function that detects if suppressMessages has been invoked upon running that same function. I was looking through {https://cran.r-project.org/doc/manuals/r-release/R-ints.html}, but I haven't found an answer. I do not understand **how** suppressMessages works.

Re: [Rd] R: determine if `suppressMessages()` has been invoked

2023-02-19 Thread Ivan Krylov
On Sun, 19 Feb 2023 15:37:33 +0100 (CET) Nino Hardt wrote: > I would like to create a function that detects if suppressMessages > has been invoked upon running that same function. Would you mind letting us know why? Just curious. Normally, I would just use message() for everything and let the u

Re: [Rd] R: determine if `suppressMessages()` has been invoked

2023-02-19 Thread Nino Hardt
Awesome, this gets the job done. To answer your question: When using C or C++ via Rinside or within a package, those functions do not listen to suppressMessages, e.g. `Rprintf` keeps printing to the console. Since it's common to use wrapper functions in R anyway, they can run `are_messages_sup

Re: [Rd] R: determine if `suppressMessages()` has been invoked

2023-02-19 Thread Ivan Krylov
On Sun, 19 Feb 2023 18:45:55 +0100 (CET) Nino Hardt wrote: > When using C or C++ via Rinside or within a package, those functions > do not listen to suppressMessages, e.g. `Rprintf` keeps printing to > the console. True, Rprintf is really convenient, but it doesn't raise any conditions and just

Re: [Rd] determine if `suppressMessages()` has been invoked

2023-02-19 Thread Simon Urbanek
Nino, that is the wrong way around as Ivan pointed out. Rprintf() is not the tool for this as explained. If you want messages, use them, it's easy to wrap it to C code: static void Rmessage(const char *msg) { SEXP msg_sym = Rf_install("message"); SEXP msg_call = PROTECT(lang2(msg_sym, P