Re: [R] Constructing a transition matrix

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Wed 07 Dec 2005 - 18:27:41 EST

Chris Stubben <stubben@lanl.gov> writes:

> 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
>

Are you looking for something like

d1 <- setdiff(dev,"seed")
A0[d1,dev] <- A[d1,dev]

?

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Dec 07 18:35:43 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:30 EST