Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:41:11+00:00 2026-05-30T00:41:11+00:00

Sometimes when I am running lots of long programs I think it would be

  • 0

Sometimes when I am running lots of long programs I think it would be nice if there was a statement or command I could add to the bottom of a file that would tell me whether R returned any error messages (or warning messages) while running a file.

I always scroll up through all of the code to visually check for error messages or warnings and keep thinking it would be nice if R simply told me at the bottom of the code whether any error messages or warnings occurred.

Can R do that? I suppose even if R can do that I would need a while to develop trust in the command line to catch all error messages or warning messages.

With SAS I used to use the find command and search the log window for the word ‘Error’ or ‘Warning’.

Thanks for any thoughts or advice about this.

Here is a very simple example of R code that returns 3 error messages.

x <- c(1,2,3,4)
y <- c(3,4)
z <- x / y
zz
a <- matrix(x, nrow=2, byrow=T)
b <- matrix(x, nrows=2, byrow=T)
z x a
z * a
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:41:13+00:00Added an answer on May 30, 2026 at 12:41 am

    I assume you are running from a GUI, where errors are not fatal. Here is a solution making use of options(error). The error handler is replaced by a function that increments a variable:

    .error.count <- 0
    old.error.fun <- getOption("error")
    new.error.fun <- quote(.error.count <- .error.count + 1)
    options(error = new.error.fun)
    
    ### your code here ###
    x <- c(1,2,3,4)
    y <- c(3,4)
    z <- x / y
    zz
    a <- matrix(x, nrow=2, byrow=T)
    b <- matrix(x, nrows=2, byrow=T)
    z x a
    z * a
    ######################
    
    cat("ERROR COUNT:", .error.count, "\n")
    options(error = old.error.fun)
    rm(.error.count, old.error.fun, new.error.fun)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long running PHP process, that sometimes hangs in a loop. This
Sometimes it is weird to encounter File not Found Error in running. But we
There is sometimes a problem with running out of memory when it got fragmented.
I'm writing an app that sometimes requires very long-running DB requests. I'd like to
I just started playing with Jython, and sometimes running jython on a .py file
When running my application I sometimes get an error about too many files open
Sometimes (pretty rarely) when I connect to a running instance of a com.sun.net.httpserver.HttpServer I
I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes
I have a ruby on rails app running a server and sometimes it needs
We are using Team City and I noticed problem during running Watin test. Sometimes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.