Skip to content
Prev 30590 / 398513 Next

removing NULL elements from a list: Thanks

Thank you very much for the very helpful responses from D. Bates, P. Dalgaard, 
J. Holtman, D. James, U. Ligges, V. Ogranovich, C. Ortega, B. D. Ripley and 
T. Plate. 


The original question is at the end.
Most of the answers were: (A is the list, with the NULLs I want to get rid of)

A[!sapply(A, is.null)]

A[!unlist(lapply(A, is.null))]

A[sapply(A, is.null)] <- NULL ## potentially confussing, as pointed out by 
B.D. Ripley


Thanks again,

Ram?n