Re: [R] how to delete the null elements in list

2013-01-25 Thread arun
Or, suu[unlist(lapply(suu,length)!=0)] #[[1]] #[1] 1 2 #[[2]]  #    [,1] [,2] #[1,]    1    3 #[2,]    2    4 A.K. - Original Message - From: Rui Barradas To: Tammy Ma Cc: "r-help@r-project.org" Sent: Friday, January 25, 2013 8:15 AM Subject: Re: [R] how to delete the nul

Re: [R] how to delete the null elements in list

2013-01-25 Thread Ben Bolker
Tammy Ma 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 >

Re: [R] how to delete the null elements in list

2013-01-25 Thread Rui Barradas
Hello, Try the following. suu <- list(NULL, NULL, 1:2, matrix(1:4, 2)) suu[!sapply(suu, is.null)] Hope this helps, Rui Barradas Em 25-01-2013 12:31, Tammy Ma escreveu: HI, I have the list: suu [[1]] NULL [[2]] NULL [[3]] item_id prod 1 2 [[4]] item_id prod 1

[R] how to delete the null elements in list

2013-01-25 Thread Tammy Ma
HI, I have the list: > 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 ?? Kind