Skip to content
Prev 82327 / 398513 Next

Constructing a transition matrix

Hi again,

I almost figured this out, but still need some help on the last part.

I can use prop.table to get survival probabilities...

A <- t(prop.table( table(trans$class, trans$fate),1) )

             rep      seed       veg
   dead 0.0000000 0.3333333 0.0000000
   rep  0.5000000 0.0000000 1.0000000
   veg  0.5000000 0.6666667 0.0000000


so now I just need to format the matrix.  I thought I could create a 
matrix of zeroes using size class names,

dev<- c("seed","veg", "rep").


A0<-matrix(numeric(9), nrow=3, dimnames=list(dev,dev) )
      seed veg rep
seed    0   0   0
veg     0   0   0
rep     0   0   0


but how do I assign values in A to the corresponding rows and columns in 
A0?  I hope there is an easy solution that I'm overlooking.


      seed veg   rep
seed    0   0     0
veg  0.67   0   0.5
rep     0   1   0.5


Thanks,

Chris
Chris Stubben wrote: