How about foo <- function(...) { m <- as.list(match.call(expand.dots=TRUE))[-1] nm <- names(m) for(i in seq_along(m)) if(!nchar(nm[i])) nm[i] <- deparse(m[[i]]) nm }
Such things are hard to do from R level, hence the use of match.call to do it at C level. On Fri, 1 Jun 2007, Mike Meredith wrote: > > > Thanks, Henrik, but 'foo' doesn't do what I want: > > x <- "some stuff" > second <- "more stuff" > > foo(first=x, second) > [1] "first" "" > > Brian's right: >> ...he wants the argument name if there is one otherwise the >> deparsed argument value, but clarification would be helpful. > > The function using this compares estimates of animal densities, CIs, etc > using different models, with one object containing the results of one model. > It extracts key results and AIC from these objects and does a summary > matrix, with lowest AIC at the top, so the row names need to reflect the > model used. > > If the object name is sufficiently explanatory -- eg. point.est.hazardRate > -- then the deparsed argument value is fine as row name. But we need the > option to be more specific if necessary, eg. with "halfNormal=x1, > hazardRate=x2". Just like 'rbind', in fact. > > Thanks, Mike > -- Brian D. Ripley, [EMAIL PROTECTED] 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@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 and provide commented, minimal, self-contained, reproducible code.