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 6386119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:59:03+00:00 2026-05-25T02:59:03+00:00

I have a dummy script below: a <- 1 b <- 2 c <-

  • 0

I have a dummy script below:

a <- 1
b <- 2
c <- 3
e <- 5

list <- letters[1:5]

for (loop in (1:length(list)))
    {print(paste(list[loop],get(list[loop]),sep="-"))
    }

> source('~/.active-rstudio-document')
[1] "a-1"
[1] "b-2"
[1] "c-3"
Error in get(list[loop]) : object 'd' not found

Currently I have a problem that since d is not present, so an error message pop up and block the processing of e.

I wonder if R has some kind of “error handling”, that is to bypass the error due to d, keep processing e, then return the error message when all valid data are processed.

Thanks.

  • 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-25T02:59:04+00:00Added an answer on May 25, 2026 at 2:59 am

    Use exists to check whether a variable exists:

    for (loop in (1:length(list))){
      if(exists(list[loop])){
        print(
            paste(list[loop], get(list[loop]), sep="-"))
      }
    }
    
    [1] "a-1"
    [1] "b-2"
    [1] "c-3"
    [1] "e-5"
    

    More generally, R has a sophisticated mechanism for catching and dealing with errors. See ?tryCatch and its simplified wrapper, ?try, for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following dummy test script: function test() { var x = 0.1
I have a dummy class where I am testing arrays. I've noticed that when
I have a generic method with this (dummy) code (yes I'm aware IList has
Let's say I have the following content: Lorem Ipsum is simply dummy text of
Image Dummy = Image.FromFile(image.png); Dummy.Save(image.bmp, ImageFormat.Bmp); what the question says i have these using
I have a table with three fields, FirstName, LastName and Email. Here's some dummy
So, I have a file called 'dummy' which contains the string: There is 100%
Have you guys had any experiences (positive or negative) by placing your source code/solution
I have an little script which logs users that login to my Pidgin/MSN account
I have the following code: <html> <head> <title>D</title> <script type=text/javascript src=jQuery.js> <script type=text/javascript> $(window).unload(

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.