[R] Existence of an object

Margaret Donald merricks.merricks at gmail.com
Sat Nov 7 04:48:04 CET 2015


I have a variable meanedf which may sometimes not be defined due to a
complex set of circumstances.
I would like to be able to find out whether or not it exists, and then
branch appropriately in my code.

I had hoped to be able to use is.null() or exists() but neither of these
returns TRUE or FALSE which is the behaviour I would like, so that I can
write some appropriate branching code.

is.null(meanedf)
Error: object 'meanedf' not found
No suitable frames for recover()

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

I would like some code which returns TRUE when meanedf exists and FALSE
when it doesn't.

Thanks, and regards,
Margaret Donald


-- 
Margaret Donald
Post Doctoral researcher
University of New South Wales
margaret.donald at unsw.edu.au
0405 834 550

	[[alternative HTML version deleted]]



More information about the R-help mailing list