From deepayan at stat.wisc.edu  Tue Sep 16 16:02:09 2003
From: deepayan at stat.wisc.edu (Deepayan Sarkar)
Date: Tue Sep 16 22:05:35 2003
Subject: [Rd] How does "subset" replace arguments? (PR#4193)
In-Reply-To: <200309161939.h8GJd2JH023713@pubhealth.ku.dk>
References: <200309161939.h8GJd2JH023713@pubhealth.ku.dk>
Message-ID: <200309161502.09158.deepayan@stat.wisc.edu>

On Tuesday 16 September 2003 14:39, axel.benz@iao.fhg.de wrote:
> Full_Name: Axel Benz
> Version: 1.7.1
> OS: Windows
> Submission from: (NULL) (137.251.33.43)
> 
> 
> Hello,
> 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)

I don't see any problem here. toString(field), evaluated in the data frame 
test, should be the single string

"Kreis2, Kreis5, Metall, Kreis1, Kreis8"

So, the comparison 

toString(field)=="Metall" 

actually does 

"Kreis2, Kreis5, Metall, Kreis1, Kreis8" == "Metall"

which being false, returns FALSE, and so you finally should get 

subset(test, FALSE)

which is what you do get.

Perhaps you misunderstood what the function toString() does.

HTH,

Deepayan

P.S. Please don't use R-bugs to report what may or may not be bugs, since all 
such reports have to be processed manually. Ask on r-help or r-devel first if 
you are not sure.


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