This is an extension of my previous question. I reviewed the linked duplicate, but I am still having trouble.
I have a data frame like the following:
> example
  name X1.8 X1.8.1 X1.8.2
1    a   -1      1      7
2    b   33      0      2
3    c    3     10     -1
4    a   -1     -1      4
5    d    5      8      5
6    e    7      6     12
7    a   -1      7      7
8    c    5     20      9
9    f   -1     -1     -1
and I want to collapse(sum) the row with the same name (column 1) but ignore the value -1 while collapsing (summing). *-1 is similar to NA. For example, the example above would become:
> example    # the goal
  name X1.8 X1.8.1 X1.8.2
1    a   -1      8      18 # the first col stays as -1 b/c all are -1
2    b   33      0       2
3    c    8     30       9
4    d    5      8       5
5    e    7      6      12
6    f   -1     -1      -1
> dput(example)
structure(list(name = structure(c(1L, 2L, 3L, 1L, 4L, 5L, 1L, 
3L, 6L), .Label = c("a", "b", "c", "d", "e", "f"), class = "factor"), 
    X1.8 = c(-1, 33, 3, -1, 5, 7, -1, 5, -1), X1.8.1 = c(1, 0, 
    10, -1, 8, 6, 7, 20, -1), X1.8.2 = c(7, 2, -1, 4, 5, 12, 
    7, 9, -1)), row.names = c(NA, 9L), class = "data.frame")
 
     
     
     
    