hi, I need to remove the list that does not have any values.Do suggest me the way to do it. result<- list()> head(result)[[1]] [,1] [,2] [,3] [[2]] [,1] [,2] [,3] [[3]] [,1] [,2] [,3] [[4]] [,1] [,2] [,3] [[5]] [,1] [,2] [,3] [1,] "HIGD1C" "SNP_A-2058537" "4" [2,] "HIGD1C" "SNP_A-1955347" "4" [3,] "HIGD1C" "SNP_A-1947169" "3" [4,] "HIGD1C" "SNP_A-2088027" "1" [5,] "HIGD1C" "SNP_A-2070418" "1" [6,] "HIGD1C" "SNP_A-4253870" "1" [7,] "HIGD1C" "SNP_A-2185340" "1" [8,] "HIGD1C" "SNP_A-1794461" "1" [9,] "HIGD1C" "SNP_A-1928826" "1" [10,] "HIGD1C" "SNP_A-1938145" "1" [11,] "HIGD1C" "SNP_A-1889970" "1" [[6]] [,1] [,2] [,3] I have 386 list elements I need to remove these empty martix.([[1]],[[2]],[[3]],[[4]].[[6]]) do help me Ramya -- View this message in context: http://www.nabble.com/List-help-tp18411519p18411519.html Sent from the R help mailing list archive at Nabble.com.
Perhaps something about like this: result[which(unlist(lapply(result, length)) != 0)] On Fri, Jul 11, 2008 at 4:57 PM, Rajasekaramya <ramya.victory at gmail.com> wrote:> > hi, > > I need to remove the list that does not have any values.Do suggest me the > way to do it. > > result<- list() > >> head(result) > > [[1]] > [,1] [,2] [,3] > > [[2]] > [,1] [,2] [,3] > > [[3]] > [,1] [,2] [,3] > > [[4]] > [,1] [,2] [,3] > > [[5]] > [,1] [,2] [,3] > [1,] "HIGD1C" "SNP_A-2058537" "4" > [2,] "HIGD1C" "SNP_A-1955347" "4" > [3,] "HIGD1C" "SNP_A-1947169" "3" > [4,] "HIGD1C" "SNP_A-2088027" "1" > [5,] "HIGD1C" "SNP_A-2070418" "1" > [6,] "HIGD1C" "SNP_A-4253870" "1" > [7,] "HIGD1C" "SNP_A-2185340" "1" > [8,] "HIGD1C" "SNP_A-1794461" "1" > [9,] "HIGD1C" "SNP_A-1928826" "1" > [10,] "HIGD1C" "SNP_A-1938145" "1" > [11,] "HIGD1C" "SNP_A-1889970" "1" > > [[6]] > [,1] [,2] [,3] > > > I have 386 list elements I need to remove these empty > martix.([[1]],[[2]],[[3]],[[4]].[[6]]) > > do help me > > Ramya > -- > View this message in context: http://www.nabble.com/List-help-tp18411519p18411519.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
Hi Ramya, Perhaps result[lapply(result, length) != 0] does the work. HTH, Jorge On Fri, Jul 11, 2008 at 3:57 PM, Rajasekaramya <ramya.victory@gmail.com> wrote:> > hi, > > I need to remove the list that does not have any values.Do suggest me the > way to do it. > > result<- list() > > > head(result) > > [[1]] > [,1] [,2] [,3] > > [[2]] > [,1] [,2] [,3] > > [[3]] > [,1] [,2] [,3] > > [[4]] > [,1] [,2] [,3] > > [[5]] > [,1] [,2] [,3] > [1,] "HIGD1C" "SNP_A-2058537" "4" > [2,] "HIGD1C" "SNP_A-1955347" "4" > [3,] "HIGD1C" "SNP_A-1947169" "3" > [4,] "HIGD1C" "SNP_A-2088027" "1" > [5,] "HIGD1C" "SNP_A-2070418" "1" > [6,] "HIGD1C" "SNP_A-4253870" "1" > [7,] "HIGD1C" "SNP_A-2185340" "1" > [8,] "HIGD1C" "SNP_A-1794461" "1" > [9,] "HIGD1C" "SNP_A-1928826" "1" > [10,] "HIGD1C" "SNP_A-1938145" "1" > [11,] "HIGD1C" "SNP_A-1889970" "1" > > [[6]] > [,1] [,2] [,3] > > > I have 386 list elements I need to remove these empty > martix.([[1]],[[2]],[[3]],[[4]].[[6]]) > > do help me > > Ramya > -- > View this message in context: > http://www.nabble.com/List-help-tp18411519p18411519.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
Thank u so much it did work Rajasekaramya wrote:> > hi, > > I need to remove the list that does not have any values.Do suggest me the > way to do it. > > result<- list() > >> head(result) > > [[1]] > [,1] [,2] [,3] > > [[2]] > [,1] [,2] [,3] > > [[3]] > [,1] [,2] [,3] > > [[4]] > [,1] [,2] [,3] > > [[5]] > [,1] [,2] [,3] > [1,] "HIGD1C" "SNP_A-2058537" "4" > [2,] "HIGD1C" "SNP_A-1955347" "4" > [3,] "HIGD1C" "SNP_A-1947169" "3" > [4,] "HIGD1C" "SNP_A-2088027" "1" > [5,] "HIGD1C" "SNP_A-2070418" "1" > [6,] "HIGD1C" "SNP_A-4253870" "1" > [7,] "HIGD1C" "SNP_A-2185340" "1" > [8,] "HIGD1C" "SNP_A-1794461" "1" > [9,] "HIGD1C" "SNP_A-1928826" "1" > [10,] "HIGD1C" "SNP_A-1938145" "1" > [11,] "HIGD1C" "SNP_A-1889970" "1" > > [[6]] > [,1] [,2] [,3] > > > I have 386 list elements I need to remove these empty > martix.([[1]],[[2]],[[3]],[[4]].[[6]]) > > do help me > > Ramya >-- View this message in context: http://www.nabble.com/List-help-tp18411519p18412113.html Sent from the R help mailing list archive at Nabble.com.