Skip to content
Prev 300168 / 398521 Next

variable (column) in a data frame

Dr. Dalgaard,

Thank you. But pre-checking with is.null() or using with()
doesn't solve the problem of catching spelling mistakes
in the name of a variable inside a data frame, when using 
the df$var notation often in a program.

Is there some way for R to behave, in relation to a variable 
inside a data frame, the same way it behaves for a variable 
not in a data frame? For example:

##----------------------------------------
a <- c(1,2,3)

## the variable exists, we get a correct answer
a==1

## the variable does not exist, R rightly points this out
aaa==1
##----------------------------------------

My point is, if we make a spelling mistake in a program when referring
to a variable inside a data frame, using the df$var notation, 
there seems to be no way of getting warned about that. 

Thank you once again.

Paulo Barata

---------------------------------------------------------------------


---------- Original Message -----------
From: peter dalgaard <pdalgd at gmail.com>
To: "Paulo Barata" <paulo.barata at ensp.fiocruz.br>
Sent: Sun, 15 Jul 2012 16:47:35 +0200
Subject: Re: [R] variable (column) in a data frame
------- End of Original Message -------