28

I am trying to skip steps loading data from large files if this has already been done earlier. Since the data ends up in (for example) mydf, I thought I could do:

if( !exists(mydf) )
{
  #... steps to do loading here.
}

I got this from How to check if object (variable) is defined in R? and https://stat.ethz.ch/R-manual/R-devel/library/base/html/exists.html

However R Studio simply complains with

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

Why does it complain instead of just returning 'true' or 'false'? Any tips appreciated.

1 Answer 1

58

You should use exists("mydf") instead exists(mydf)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.