Tammy Ma <metal_licaling <at> live.com> writes: > > suu > [[1]] > NULL > [[2]] > NULL > [[3]] > item_id prod > 1 2 > [[4]] > item_id prod > 1 2 > 2 4 > > how to delete all "NULL" elements from suu to get only > > >suu > [[3]] > item_id prod > 1 2 > [[4]] > item_id prod > 1 2 > 2 4
How about suu[!sapply(suu,is.null)] ? (Haven't tested, but I would expect it to work ... Of course, the result won't have elements [[3]] and [[4]], it will have elements [[1]] and [[2]] ... Ben Bolker ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.