Hi R-list, I would like to know how to perform any elimination of attribute (column) in R. E.g I have:- 20,21,22,23,24,25,normal 1,2,3,4,5,5,normal 0,1,0,2,3,4,abnormal ... I intend to do a checking on each column:- If the column sum of abnormal is 0 but the column sum of normal is nonzero, i wanted to eliminate this attribute. And so on and so forth observing other attributes across the list. In the end, I wanted to form information as a table. Desired Output:- 21,23,24,25,normal 2,4,5,5,normal 1,2,3,4,abnormal It is some sort of removing noise from the data. Appreciate alot. Thanks. Rgrds, [[alternative HTML version deleted]]
Patrick Connolly
2008-Sep-29 19:18 UTC
[R] How to remove columns of table in R recursively
On Tue, 30-Sep-2008 at 12:37AM +1000, Jason Lee wrote: |> Hi R-list, |> |> I would like to know how to perform any elimination of attribute (column) in |> R. |> |> E.g I have:- |> |> 20,21,22,23,24,25,normal |> 1,2,3,4,5,5,normal |> 0,1,0,2,3,4,abnormal |> ... |> |> I intend to do a checking on each column:- |> |> If the column sum of abnormal is 0 but the column sum of normal is nonzero, |> i wanted to eliminate this attribute. And so on and so forth observing other |> attributes across the list. In the end, I wanted to form information as a |> table. |> |> Desired Output:- |> 21,23,24,25,normal |> 2,4,5,5,normal |> 1,2,3,4,abnormal |> |> It is some sort of removing noise from the data. Is this the sort of thing you want to do?> aa <- data.frame(A = 1:5, B = 12:8, C = c(0, 4, 3, 0, 1)) > aaA B C 1 1 12 0 2 2 11 4 3 3 10 3 4 4 9 0 5 5 8 1> aa[!aa$C == 0,]A B C 2 2 11 4 3 3 10 3 5 5 8 1 -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Middle minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.