r - lapply() when function returns NULL -



r - lapply() when function returns NULL -

is there method stop lapply() returning null values each element of list when function doesn't have return().

here's pretty basic example:

x <- function(x) { return(null) } a.list <- list(a=1,b=2,c=3) lapply(a.list, x)

the output is:

$a null $b null $c null

my goal not have output, @ all.

update: usage case follows. i'm using lapply() pump out xtable() text , i'm sink()'ing rnw file. null output bugging automation.

two options come mind:

either

trash_can <- lapply(a.list, x)

or

invisible(lapply(a.list, x))

the first 1 makes me wonder if there analog of linux's /dev/null in r can utilize redirect stuff don't want. problem creating variable trash_can hang around , utilize memory unless rm(trash_can). don't think that's problem here.

r

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -