Re: [R] lapply without return values?

From: Berwin A Turlach <>
Date: Fri, 25 Jan 2008 17:05:11 +0800

G'day Rainer,

On Fri, 25 Jan 2008 10:34:32 +0200
Rainer M Krug <> wrote:


> > p <- data.frame(runif(10), runif(10), runif(10))
> > lapply( p, function(ps) {x11(); plot(ps)} )
> which results in three graphs and a printout:
> How can I avoid this printout without using
> tmp <- lapply( p, function(ps) {x11(); plot(ps)} )?


like in invisible(lapply( p, function(ps) {x11(); plot(ps)} ))

Note, your solution seems to involve less keystroke but has the disadvantage of creating an object in your workspace.

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)})

To save keystrokes in the long run. :)

HTH. Cheers,

        Berwin mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 25 Jan 2008 - 09:11:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jan 2008 - 11:30:08 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive