[R] Subset and logical operator error

Sébastien pomchip at free.fr
Tue Jun 12 23:05:54 CEST 2007


Hello,

It looks to me as if the ! logical operator cannot be called when 
subsetting a data.frame. In the example below, the value column has two 
factor levels (but my typical datasets have more), and what I am trying 
to do is to exclude all lines for which the "value" is different from 
"A". I have got a syntax error message everytime I try to use the 
subset() function. Unfortunatelly, the help on the subset function or 
the logical operators is not really specific on the way to implement 
this type of exclusion subset?

Can you please point to me my syntax mistake or indicate a method to get 
this type of data.frame subset ?

Thank you in advance

  ID value
1  1   1.2
2  2   1.2
3  3   1.2
4  4   1.2
5  5     A
6  6     A
7  7     A
8  8     A
subset(mdat,value!"A")

Error: syntax error, unexpected '!', expecting ',' in "subset(mdat,value!"

Sebastien



More information about the R-help mailing list