Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using an exists statement in R

I have made a progress bar using the winProgressBar method in R. What I want to do is if someone instantiates my program while it is doing all of its processing, I want the current progress bar to close. I tried using a statement that says

if(exists(progressBar)) {
  close(progressBar);
}

but I get an error from the console that says

Error in exists(progressBar) : object 'progressBar' not found

I know that it will not exist during the first iteration of my program, but there is no reason that I can find that would make an if statement cause the program to crash.

like image 996
user1876508 Avatar asked Apr 14 '26 19:04

user1876508


1 Answers

If you read the help for exists you will see the following under Arguments

x a variable name (given as a character string).

So

exists('progressBar')

will return TRUE or FALSE.

like image 107
mnel Avatar answered Apr 16 '26 09:04

mnel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!