Re: [R] variable (column) in a data frame

2012-07-17 Thread Bert Gunter
ar notation to issue an error when referring to a non-existent > variable inside the data frame? > > Thank you very much. > > Paulo Barata > > ----- > > > ------ Original Message --- > From: "Frans Marcelissen" > To: &qu

Re: [R] variable (column) in a data frame

2012-07-17 Thread Sarah Goslee
Hi, On Tue, Jul 17, 2012 at 10:40 AM, Paulo Barata wrote: > > Dear Frans and Peter, > > Yes, the notation df[,'var'] is able to catch a non-existent > variable var inside a data frame df. But the notation df$var > isn't. > > So we have this situation, where two different notations, which > (as fa

Re: [R] variable (column) in a data frame

2012-07-17 Thread Paulo Barata
--- -- Original Message --- From: "Frans Marcelissen" To: "'Paulo Barata'" , Sent: Mon, 16 Jul 2012 14:25:21 +0200 Subject: RE: [R] variable (column) in a data frame > Hoi Pauli, > There is a difference between two ways of accessing co

Re: [R] variable (column) in a data frame

2012-07-16 Thread Frans Marcelissen
Hoi Pauli, There is a difference between two ways of accessing columns in a matrex: > df$aaa NULL > df["AAA"] Error in `[.data.frame`(df, "AAA") : undefined columns selected So df["AAA"] or df[,"AAA"] gives the error message you expect. --- Frans -Oorspronkelijk bericht- V

Re: [R] variable (column) in a data frame

2012-07-15 Thread Peter Ehlers
iginal Message --- From: Peter Ehlers To: Paulo Barata Cc: "r-help@r-project.org", peter dalgaard Sent: Sun, 15 Jul 2012 09:29:11 -0700 Subject: Re: [R] variable (column) in a data frame On 2012-07-15 08:41, Paulo Barata wrote: Dr. Dalgaard, Thank you. But pre-checking with

Re: [R] variable (column) in a data frame

2012-07-15 Thread arun
Hi, I guess you can try this: #You will get the same result here:  df$aaa==2 logical(0) !df$aaa==2 logical(0) #But it is different for the variable present in the dataframe  df$a==4 [1] FALSE FALSE FALSE  !df$a==4 [1] TRUE TRUE TRUE  identical(df$aaa==2,!df$aaa==2) [1] TRUE  identical(df$a==4,!

Re: [R] variable (column) in a data frame

2012-07-15 Thread Berend Hasselman
Paulo Barata-3 wrote > > 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 >

Re: [R] variable (column) in a data frame

2012-07-15 Thread Paulo Barata
nt: 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 pr

Re: [R] variable (column) in a data frame

2012-07-15 Thread Peter Ehlers
ank you once again. Paulo Barata - -- Original Message --- From: peter dalgaard To: "Paulo Barata" Sent: Sun, 15 Jul 2012 16:47:35 +0200 Subject: Re: [R] variable (column) in a data frame On Jul 15, 2012, at 16:30 , Paulo Barata wrote: To the R help

Re: [R] variable (column) in a data frame

2012-07-15 Thread peter dalgaard
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. > >

Re: [R] variable (column) in a data frame

2012-07-15 Thread Paulo Barata
o Barata - -- Original Message --- From: peter dalgaard To: "Paulo Barata" Sent: Sun, 15 Jul 2012 16:47:35 +0200 Subject: Re: [R] variable (column) in a data frame > On Jul 15, 2012, at 16:30 , Paulo Barata wrote: > > > > > To the R help li

Re: [R] variable (column) in a data frame

2012-07-15 Thread John Kane
This seems more or less correct to me. 1> sum(df$a==1) [1] 1 1> sum(df$a==2) [1] 1 1> sum(df$aaa==2) [1] 0 There is no df$aaa so the length is 0 which is what I think you are asking. What am I missing? John Kane Kingston ON Canada > -Original Message- > From: paulo.bar...@ensp.fiocruz