search for: fun_factory

Displaying 2 results from an estimated 2 matches for "fun_factory".

2007 Jun 22
2
extract index during execution of sapply
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
2007 Jun 24
2
matlab/gauss code in R
...nibas.ch> > Cc: R help list <r-help en stat.math.ethz.ch> > Message-ID: <6phodj85dno.fsf en gopher4.fhcrc.org> > Content-Type: text/plain; charset=us-ascii > > Christian, > > A favorite of mine is to use lexical scope and a 'factory' model: > > > fun_factory <- function() { > + i <- 0 # 'state' variable(s), unique to each fun_factory > + function(x) { # fun_factory return value; used as sapply FUN > + i <<- i + 1 # <<- assignment finds i > + x^i...