Dr. Dalgaard, Thank you. You are right, with() is able to catch spelling errors in the name of variables inside a data frame.
But couldn't some error or warning be included in R when referring to a non-existent variable inside a data frame with the df$var notation, without the use of with()? Is there any reason why R does not have such a kind of error message? Thank you again. Paulo Barata --------------------------------------------------------------------- ---------- Original Message ----------- From: peter dalgaard <pda...@gmail.com> To: "Paulo Barata" <paulo.bar...@ensp.fiocruz.br> Cc: r-help@r-project.org Sent: Sun, 15 Jul 2012 18:14:22 +0200 Subject: Re: [R] variable (column) in a data frame > 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....@cbs.dk Priv: pda...@gmail.com > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. ------- End of Original Message ------- ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.