[R] Constructing a transition matrix

2005-12-07 Thread Hans Gardfjell
If you order your factor levels in your vectors in the order you want in the output, then the prop.table(prop()) command will give you what you want. But you have to reorder the factor levels so that the levels commands give the following output: levels(trans$class) [1] seed veg repr

Re: [R] Constructing a transition matrix

2005-12-07 Thread Chris Stubben
Hi Peter, Thanks for pointing out the set functions. I can use setdiff to find missing rows setdiff(dev, rownames(A)) [1] seed and intersect to find common rows d1- intersect(dev, rownames(A) ) [1] veg rep I was trying to use a negative index like A[-1,] to remove the dead row, but d1 is a

[R] Constructing a transition matrix

2005-12-06 Thread Chris Stubben
Hi, I would like to construct a transition matrix from a data frame with annual transitions of marked plants. plant-c(1:6) class-c(seed,seed, seed, veg, rep, rep) fate-c(dead, veg,veg,rep, rep, veg) trans-data.frame(plant, class, fate) plant class fate 1 1 seed dead 2 2 seed veg

[R] Constructing a transition matrix

2005-12-06 Thread Chris Stubben
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.000 0.333 0.000 rep 0.500 0.000

Re: [R] Constructing a transition matrix

2005-12-06 Thread Peter Dalgaard
Chris Stubben [EMAIL PROTECTED] 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.000