Hi [email protected] napsal dne 18.08.2009 10:14:26:
> Hi Everbody > > Could somebody help me.? > > I need to remove the columns where the sum of it components is equal to > zero. > > For example > > > a<-matrix(c(0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0), ncol=4) > > a > [,1] [,2] [,3] [,4] > [1,] 0 0 0 1 > [2,] 0 1 0 1 > [3,] 0 0 0 0 > [4,] 0 1 0 0 > [5,] 0 0 0 1 > [6,] 0 0 0 0 > > Columns 1 and 3 should be removed > > the result should be the dollowing matrix > > [,2] [,4] > [1,] 0 1 > [2,] 1 1 > [3,] 0 0 > [4,] 1 0 > [5,] 0 1 > [6,] 0 0 a[,!colSums(a)==0] Beware of "==" and finite precision of floating point numbers (see FAQ) Regards Petr > > Thanks again > > > -- > Alberto Lora Michiels > Rue du ProgrĨs, 6B > 7860 Lessines > GSM 32(0)496659457 > > [[alternative HTML version deleted]] > > ______________________________________________ > [email protected] 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. ______________________________________________ [email protected] 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.

