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
and I want to collapse(sum) the row with the same name (column 1) but ignore the value -1 while collapsing (summing). For example, the example above would become:
> example    # the goal
  name X1.8 X1.8.1 X1.8.2
1    a    1      8      18
2    b   33      0       2
3    c    8     30       9
4    d    5      8       5
5    e    7      6      12
> dput(example)
structure(list(name = structure(c(1L, 2L, 3L, 1L, 4L, 5L, 1L, 
3L), .Label = c("a", "b", "c", "d", "e", "f"), class = "factor"), 
    X1.8 = c(1, 33, 3, -1, 5, 7, -1, 5), X1.8.1 = c(1, 0, 10, 
    -1, 8, 6, 7, 20), X1.8.2 = c(7, 2, -1, 4, 5, 12, 7, 9)), row.names = c(NA, 
8L), class = "data.frame")
Edit for question:
will this work if there are some rows with -1? For example,
  > 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
 
     
    