Dear all, I have a problem with match.arg(). Occasionally, I get the error message: Error in arg == choices : comparison (1) is possible only for vector types and upon grepping through the R code, I found that the only place the string "arg == choices" appears is in match.arg(), and indeed, I call this function in a function of mine that starts like this: ramp <- function(n, type=c("point", "nolens")) { type <- match.arg(type) it seems like standard usage from the example in the docs. The strange thing is that I can run my function thousands of times without this error occuring, and sometimes it happens without any change of input parameters (there are however drawing of random numbers involved, that is what the ''r'' of ''ramp'' indicates). Any ideas? Best, Kjetil -- Kjetil Kjernsmo Graduate astronomy-student Problems worthy of attack University of Oslo, Norway Prove their worth by hitting back E-mail: kjetikj at astro.uio.no - Piet Hein Homepage <URL:http://www.astro.uio.no/~kjetikj/> Webmaster at skepsis.no -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Kjetil Kjernsmo <kjetil.kjernsmo at astro.uio.no> writes:> I have a problem with match.arg(). > > Occasionally, I get the error message: > Error in arg == choices : comparison (1) is possible only for vector types...> The strange thing is that I can run my function thousands of times without > this error occuring, and sometimes it happens without any change of input > parameters (there are however drawing of random numbers involved, that is > what the ''r'' of ''ramp'' indicates).Well, what would seem to be happening is that ramp is getting called with a strange 2nd arg, most likely a function, as in> f<-function(x=c("aardvark","bison"))+ {match.arg(x)}> f(ls)Error in arg == choices : comparison (1) is possible only for vector types You could try setting options(error=quote(dump.frames())) to figure out what is going on (see help(dump.frames)). It may be that something has been corrupted by a garbage collection at just the wrong time, so if debugging doesn''t reveal a bug in your own code and things look strange, drop us a line with some more info (preferably with simplified code to reproduce the effect). -- 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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._