Message-ID: <2A292369-4B18-4D60-9EFD-7AB9810BA527@gmail.com>
Date: 2012-07-15T16:14:22Z
From: Peter Dalgaard
Subject: variable (column) in a data frame
In-Reply-To: <20120715153217.M30779@ensp.fiocruz.br>
On Jul 15, 2012, at 17:41 , Paulo Barata wrote:
>
> 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:
You could try reading the 2nd half of my one-line reply....
>>
>> You can pre-check for is.null(df$aaa) or use with(df, sum(aaa==2)).
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com