[R] Bug? using { as a function in lapply

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Sep 28 23:40:33 CEST 2004


Gabor Grothendieck <ggrothendieck at myway.com> writes:

> Thanks for pointing out that this is already fixed in the upcoming 
> version of R.

It isn't. Look closer.

I'm not sure this qualifies as a bug though. It boils down to

> f <- function(...){...}
> f()
Error in f() : ... used in an incorrect context

This doesn't work in S-PLUS either:

> f <- function(...){...}
> f()
Problem in f(): "..." may only be used as an argument in a call
Use traceback() to see the call stack

But S(-PLUS) doesn't actually have a function "{", it's part of syntax
but not actually put into functions (and if R had better deparsing,
may it could do likewise).

-------------
 
> Witold Eryk Wolski <wolski <at> molgen.mpg.de> writes:
> 
> : 
> : Hi,
> : 
> :  > "{" <- function(x,y)y
> :  > "{"(1,9)
> : [1] 9
> :  > lapply(1:2, "{", 9)
> : [[1]]
> : [1] 9
> : 
> : [[2]]
> : [1] 9
> : 
> :  > R.version.string
> : [1] "R version 2.0.0, 2004-09-20"
> : 
> : /E
> : 
> : Gabor Grothendieck wrote:
> : 
> : >This seems like a bug to me.  Can someone verify this?  
> : >
> : >First we define a function f that returns its second argument and 
> : >lapply it to 1:2 using 9 as the second argument and all seems well.
> : >
> : >Note that "{" as a function does the same thing as f, as illustrated 
> : >with f(1,9) and "{"(1,9); however, when we attempt to use "{" in the 
> : >very same way we used f in lapply, we get an error message about ... 
> : >being used in an incorrect context, as shown.
> : >
> : >I am using R on windows with the version shown at the end.
> : >
> : >
> : >R> f <- function(x,y)y
> : >R> f(1,9)
> : >[1] 9
> : >R> lapply(1:2, f, 9)
> : >[[1]]
> : >[1] 9
> : >
> : >[[2]]
> : >[1] 9
> : > 
> : >R> "{"(1,9)
> : >[1] 9
> : >R> lapply(1:2, "{", 9)
> : >Error in lapply(1:2, "{", 9) : ... used in an incorrect context
> : >
> : >R> R.version.string
> : >[1] "R version 1.9.1, 2004-08-03"
> : >
> : >______________________________________________
> : >R-help <at> stat.math.ethz.ch mailing list
> : >https://stat.ethz.ch/mailman/listinfo/r-help
> : >PLEASE do read the posting guide! http://www.R-project.org/posting-
> guide.html
> : >
> : >  
> : >
> :
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list