ripley@stats.ox.ac.uk
2001-Mar-03 20:56 UTC
[Rd] Context problem with ... and rbind (PR#860)
R 1.2.2, Solaris and Linux: f <- function(x, ...) { g <- function(x, ...) x rbind(numeric(), g(x, ...)) }> f(1:3)Error in rbind(numeric(), g(x, ...)) : ... used in an incorrect context S-PLUS 3.4 gives [,1] [,2] [,3] [1,] 1 2 3 as I would expect. f <- function(x, ...) { g <- function(x, ...) x tmp <- g(x, ...) rbind(numeric(), tmp) }> f(1:3)does work, and I believe this should be equivalent. This is an abstract of code used in the latest S version of the boot package. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk writes:> f <- function(x, ...) > { > g <- function(x, ...) x > rbind(numeric(), g(x, ...)) > } > > f(1:3) > Error in rbind(numeric(), g(x, ...)) : ... used in an incorrect contextIt's not really rbind that is the culprit here, but the deparsing of its argument. A near-minimal version of what I think is the same issue is f <- function(x, ...) h(g(x, ...)) g <- function(x, ...) x h <- function(...)substitute(list(...)) f(1) #Error in h(g(x, ...)) : ... used in an incorrect context Also, the following is perplexing, given the definition of quote():> quote(list(...))list(...)> substitute(list(...))Error: ... used in an incorrect context -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Reasonably Related Threads
- cbind/rbind inconsistency with NULL parameter (PR#3595)
- (PR#9917) rbind.data.frame converts character column to
- (PR#9578) rbind.data.frame reacts on levels without
- cbind is not generic as claimed, omits labels where S has them (PR#241)
- under certain conditions, model.matrix appears to lack one (PR#648)