Emily O'Connor
2012-Apr-26 09:17 UTC
[R] How to delete rows from dataframe that sum to zero
Hello, I am trying to figure out how to delete all rows which sum to zero from a dataframe. I do not have a column with the sum of each column yet, so perhaps that would need to be done first? Thank you for any help anyone can offer with this. Emily PS sorry if this question has already been answered in a previous thread, I did look through them & one seemed relevant, but I couldn't really understand the solution! -- View this message in context: http://r.789695.n4.nabble.com/How-to-delete-rows-from-dataframe-that-sum-to-zero-tp4589289p4589289.html Sent from the R help mailing list archive at Nabble.com.
Here's an example a=data.frame( sample(0:1,20,rep=T), sample(0:1,20,rep=T) ) # make 2 random columns of length 20. a.no0 = a[ rowSums(a)!=0, ] -- View this message in context: http://r.789695.n4.nabble.com/How-to-delete-rows-from-dataframe-that-sum-to-zero-tp4589289p4589308.html Sent from the R help mailing list archive at Nabble.com.