[Rd] How does "subset" replace arguments? (PR#4193)

axel.benz at iao.fhg.de axel.benz at iao.fhg.de
Tue Sep 16 22:39:02 MEST 2003

Full_Name: Axel Benz
Version: 1.7.1
OS: Windows
Submission from: (NULL) (

I guess many people will answer me again that this is a S language feature, but
I am only a stupid computer scientist and I simply do not understand this logic,
despite of reading a lot about S:

> test
   field           tuckey
4  Kreis2          -1
5  Kreis5          -2
9  Metall          -3
17 Kreis1          -4
19 Kreis8          -5

> subset(test,field=="Metall")
  field       tuckey
9 Metall      -3

> subset(test,toString(field)=="Metall")
[1] field   tuckey
<0 rows> (or 0-length row.names)

This happens everytime I use a function with the column name ("field", in this
case) as parameter in the  logic expression in "subset", instead of using the
column name on top level. I have the impression that the column name is only
replaced when standing in top level position. I would call that "very lazy
evaluation" ;-) ;-)
Thank you for a friendly answer, this language is realy weird to me.

More information about the R-devel mailing list