[R] extract index during execution of sapply
Christian Bieli
christian.bieli at unibas.ch
Fri Jun 22 12:31:39 CEST 2007
Hi there
During execution of sapply I want to extract the number of times the
function given to supply has been executed. I came up with:
mylist <- list(a=3,b=6,c=9)
sapply(mylist,function(x)as.numeric(gsub("[^0-9]","",deparse(substitute(x)))))
This works fine, but looks quite ugly. I'm sure that there's a more
elegant way to do this.
Any suggestion?
Christian
More information about the R-help
mailing list