Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return a error message in R?

Tags:

r

I was wondering how one is able to produce error messages in R, especially from within a function?

like image 659
petermeissner Avatar asked Oct 04 '12 09:10

petermeissner


People also ask

How do I catch an error message in R?

In R Programming, there are basically two ways in which we can implement an error handling mechanism. Either we can directly call the functions like stop() or warning(), or we can use the error options such as “warn” or “warning. expression”.

How do I report an error in R?

If your bug is in the language, though, or the Core-supported packages, you should submit your report to R's Bugzilla. NOTE: due to abuse by spammers, since 2016-07-09 only “members” (including all who have previously submitted bugs) can submit new bugs on R's Bugzilla.

What does stop () do in R?

The stop R function generates an error message and stops executing the current R code.


2 Answers

Since you don't specify what you really want, all I just can say is take a look at

?message # prints a message but not stop execution ?warning # prints a warning message but not stop execution ?stop # stops execution of the current expression and executes an error action. 
like image 189
Jilber Urbina Avatar answered Oct 07 '22 01:10

Jilber Urbina


Simply include stop() inside your function/script

If you'd like an error message, include it inside stop() like so

stop("This is an error message") 
like image 41
stevec Avatar answered Oct 07 '22 00:10

stevec