On Feb 21, 2011, at 4:03 PM, IgnacioQM wrote:
Hi,
I need to filter my data:
I think its easy but i'm stuck so i'll appreciate some help:
I have a data frame with 14 variables and 6 million rows. About half
of this
rows have a value of "0" in 12 variables (the other two variables
always
have values). How can I delete the rows in which all 12 variables
have the
value of "0".
example (from my data, variable 14 is missing):
1783 81 85 78 89 71 97 76
66 88
95 95 98 -57.48258
1784 81 86 79 90 71 97 77
66 88
95 95 98 -57.43768
1785 81 86 79 90 71 98 77
66 89
95 94 98 -57.39278
1786 0 0 0 0 0 0 0
0 0
0 0 0 -57.34788
1787 0 0 0 0 0 0 0
0 0
0 0 0 -57.30298
1788 80 86 80 90 72 98 78
66 88
93 93 96 -57.25808
1789 77 83 78 88 70 95 76
63 86
91 90 93 -57.21318
1790 77 84 79 89 70 96 76
64 87
91 90 93 -57.16828
I would need to delete rows 1786 & 1787.
something along the lines of:
dfrm[ -apply(dfrm, 1, function(x) all(x==0) ), ]
I tried subset with variable1>"0"&variable2>"0", but it wasn't
useful 'cause
it only took the rows that didn't have a 0 in any of the variables;
I only
need in ALL of the variables simultaneously.
Thanks,
Ignacio
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-delete-rows-with-specific-values-on-all-columns-variables-tp3318115p3318115.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.
David Winsemius, MD
West Hartford, CT
______________________________________________
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.