[R] lapply without return values?

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri Jan 25 11:24:38 CET 2008


Berwin A Turlach wrote:
> Of course, you could always do something like:
>
>   
>> ilapply <- function(...) invisible(lapply(...))
>>     
>
> ## perhaps better:
> ## ilapply <- function(X, FUN, ...) invisible(lapply(X, FUN, ...))
>
>   
>> ilapply(p, function(ps) {x11(); plot(ps)})
>>     
lapply just a for loop with convenience features, if the features are
inconvenient, just use a for loop....

So, if you want to encapsulate that (not that I really see a need for
it), how about

zapply <- function(X, FUN, ...)  for(x in X) FUN(x, ...)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list