[R] Test for X=1 fails, test for >0 works, data in text file is 1

William Dunlap wdunlap at tibco.com
Tue Jul 7 22:08:05 CEST 2009


subset(), like many R methods, has an argument list that
ends with '...', meaning that it will not tell you that an argument
you gave it by name= is not in the official list of arument names.
If the ... were not there then you would have gotten an error
message.  E.g., the following makes a version of subset.data.frame
without the ... argument:

> sb<-subset.data.frame
> formals(sb) <- formals(sb)[1:4]
> data(cars)
> sb(cars, speed==19)
   speed dist
36    19   36
37    19   46
38    19   68
> sb(cars, speed=19)
Error in sb(cars, speed = 19) : unused argument(s) (speed = 19)

subset(cars, speed=19) silently ignores the argument you 
named "speed" and returns the entire cars dataset.

I think that it is unfortunate that the method system requires
these ... arguments, as it leads users to waste time tracking down
typing errors that would otherwise be flagged.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Mark Knecht
> Sent: Tuesday, July 07, 2009 12:39 PM
> To: Henrique Dallazuanna
> Cc: r-help
> Subject: Re: [R] Test for X=1 fails, test for >0 works,data 
> in text file is 1
> 
> On Tue, Jul 7, 2009 at 12:17 PM, Henrique 
> Dallazuanna<wwwhsd at gmail.com> wrote:
> > Try this:
> >
> > MyResults.GroupA <- subset(MyResults, PosType == 1)
> >
> >
> <SNIP>
> 
> Darn those small screen fonts. I never noticed that! Every example I'm
> looking at jsut looks like a single '=' until you pointed it out!
> 
> Thanks to everyone who responded.
> 
> Cheers,
> Mark
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 




More information about the R-help mailing list