Ok guys this one I tried for awhile but got nowhere. I have a data frame (df) as follows:
df <- data.frame(
one = c(2,1,2,0,0,1),
two = c(4,5,3,0,1,3),
three = c(1,0,2,0,7,4),
four = c(3,2,1,0,0,0)
)
row.names(df) <- c('mm1','mm2','mm3', 'GC1', 'GC2', 'GC3')
df
one two three four
mm1 2 4 1 3
mm2 1 5 0 2
mm3 2 3 2 1
GC1 0 0 0 0
GC2 0 1 7 0
GC3 1 3 4 0
I want to remove all columns corresponding to any rowname of ^GC that has any value greater than 0. So in this case I would remove columns 1,2, and 3. The result would look like this:
four
mm1 3
mm2 2
mm3 1
GC1 0
GC2 0
GC3 0
Then after this is done, I would like to remove all rows of ^GC (which should now all be 0's across all columns). The final result would look like this:
four
mm1 3
mm2 2
mm3 1
Maybe there is a simpler way to combine these two steps, but I want to be sure that I eliminate the column from the dataset that has a value in one of the ^GC rows.
!?!?!?
Thanks!