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

  • Home
  • SEARCH
  • 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 6868549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:26:52+00:00 2026-05-27T03:26:52+00:00

I am having an issue: I am running a loop to process multiple files.

  • 0

I am having an issue:
I am running a loop to process multiple files. My matrices are enormous and therefore I often run out of memory if I am not careful.

Is there a way to break out of a loop if any warnings are created? It just keeps running the loop and reports that it failed much later… annoying. Any ideas oh wise stackoverflow-ers?!

  • 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-27T03:26:53+00:00Added an answer on May 27, 2026 at 3:26 am

    You can turn warnings into errors with:

    options(warn=2)
    

    Unlike warnings, errors will interrupt the loop. Nicely, R will also report to you that these particular errors were converted from warnings.

    j <- function() {
        for (i in 1:3) {
            cat(i, "\n")
            as.numeric(c("1", "NA"))
    }}
    
    # warn = 0 (default) -- warnings as warnings!
    j()
    # 1 
    # 2 
    # 3 
    # Warning messages:
    # 1: NAs introduced by coercion 
    # 2: NAs introduced by coercion 
    # 3: NAs introduced by coercion 
    
    # warn = 2 -- warnings as errors
    options(warn=2)
    j()
    # 1 
    # Error: (converted from warning) NAs introduced by coercion
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issue with memory after running many times my app. java.lang.OutOfMemoryError: bitmap
Having an issue where the URL rewrite is running but the server will not
I am currently having an issue with BackgroundWorker running on Windows Server 2003. I
I'm running into some issues with having a lot of UIImages in memory, so
I am having a synchronization issue with third party API. My for loop seem
I'm having an issue running unit tests for authorization in a Pylons app. It
I'm having an issue with running Subsonic in medium trust and don't know if
I am having an issue with running Machine Specification tests using Resharper 5.0. The
Running KODO 4.2 and having an issue inefficient queries being generated by KODO. This
A client is having an issue running java2ws on some of their code, which

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.