[R] Remove zero row from data.frame

Rees, David david.rees at citi.com
Fri Oct 5 11:47:56 CEST 2007


Hi,

Sorry that this is such a basic question, but I am having trouble with
the following.

I would like to remove all rows where the data is all zeros in a
data.frame such as the following

> x
         date        a        b        c
1  2007.09.25 99.89844 100.0586 100.0840
4  2007.09.26 99.89844 100.0586 100.0801
7  2007.09.27  0.00000   0.0000   0.0000
10 2007.09.28 99.89648 100.0391 100.0664
13 2007.10.01 99.88672 100.0254 100.0566

i.e. in this example remove the 3rd row. 

There could several, or no row with zeros, and in this example there are
only 4 columns, but in general there are several hundred (so hopefully
no typing of "a", "b", "c" or "x$a", "x$b" etc.)

Many thanks in advance for any help.

Regards,
D



More information about the R-help mailing list