The following code returns a list with the 2nd element as NULL. I'm wondering what the best way to get rid of NULL element in an 'apply()'s result. > lapply(1:3, function(x) { + if(x==2) { + return(NULL) + } else { + return(x) + } + } + ) [[1]] [1] 1 [[2]] NULL [[3]] [1] 3