[Rd] How does "subset" replace arguments? (PR#4193)
Deepayan Sarkar
deepayan at stat.wisc.edu
Tue Sep 16 16:02:09 MEST 2003
On Tuesday 16 September 2003 14:39, axel.benz at 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.
More information about the R-devel
mailing list