On 3/20/2007 6:36 AM, Thomas McCallum wrote: > Hi Everyone, > > When I have a load of functions which have various arguments passed > via the ellipsis argument it keeps on assigning them as symbol making > them unusable to the function. My current work around involves using > do.call but this is rather cumbersome. > > Does anyone know why it suddenly changes the types to symbol and if > there is a way to get the actual data pointed to by the symbol? (I > have tried eval but that does not work and most functions just treat a > symbol as a string). > > ( An example which shows the type conversion is given below with the > output - the key is the following "dataX=data" which makes the object > data passed as a symbol and not the actual data).
match.call() doesn't evaluate the args, it just shows you the unevaluated call. If you print your "extras" variable in your function, you'll see $dataX data because you called the function with dataX=data. If you'd called it as x(dataY = 1+2) you'd see 1 + 2 [1] "language" for the same reason. If you want to evaluate the ... args, use list(...) instead of match.call. Duncan Murdoch > Many thanks > > Tom > > ====EXAMPLE CODE==== > data=c(1,2,3,4,5,6,7,8,9); > > x <- function( ... ) { > args <- list(); > extras <- match.call(expand.dots = FALSE)$...; > for( i in names(extras) ) { > args[[ i ]] <- extras[[ i ]]; > print(args[[i]]); > print(typeof(extras[[i]])); > } > > > } > > cat("TYPE OF DATA:"); > print(typeof(data)); > x(dataX=data); > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel