Q:

How to creat new matrix out of a matrix in R?

I have big matirx with folowing structure. I just want to creat new matrix out of it.
but I don't know how to implement it in R. would someone help me to implement it ? 
my matrix: 
      a    b   c     
 [1,] "10" "m" "MIT1"
 [2,] "15" "m" "MIT1"
 [3,] "20" "s" "MIT2"
 [4,] "30" "m" "MIT2"
 [5,] "40" "p" "MIT4"
 [6,] "50" "m" "MIT4"
 [7,] "60" "m" "MIT4"
 [8,] "65" "m" "MIT4"
 [9,] "70" "m" "MIT4"
> 

My new matirx should results in following rule :
For every IDs in column c, if the corresponding coordinate in column b is m, sum all the corresponding coordinates in column a and put it in new matrix.
the expected output for the above matrix would be :
> H
  a     b   c     
q "25"  "m" "MIT1"
w "30"  "m" "MIT2"
e "255" "m" "MIT4"

A:

Easier to convert to data.frame here. M was the original matrix.
> library(plyr)
> D <- data.frame(M, stringsAsFactors = FALSE)
> ddply(D[D$b == 'm',], .(c, b), summarize, sum = sum(as.numeric(a)))
     c b sum
1 MIT1 m  25
2 MIT2 m  30
3 MIT4 m 245

