Skip to content

is.variable ? is.initialized ?

4 messages · myshare, Rolf Turner

#
hi guys,

How do you check if variable is initialized/created, tried :

is.nan(xxx)
is.null(xxx)
is.na(xxx)
exists(xxx)

all of them return :

Error: object "xxx" not found

I need true/false result ?

thanx
#
On 15/05/2009, at 11:19 AM, myshare wrote:

            
exists("xxx") # Note the quote marks; requires the variable name as a  
string.

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
#
thanx, I forgot something how then do you check if u have something like this :

exists("xxx$array")

this does not seem to work !! ;\
On Thu, May 14, 2009 at 11:26 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
#
On 15/05/2009, at 11:34 AM, myshare wrote:

            
Of course not.

I don't think what you want is built in.  But you can easily
cobble something together:

	!is.na(match("array",names(xxx)))

will do it, I think.  (Not tested.)

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}