Description Usage Format Examples
Three years of census data for a hypothetical plant with three stage classes
1 |
A data frame with 41 census rows and 4 columns:
plant
Plant id number
year
Year of census
stage
Stage class: seedling, vegetative, or reproductive
fruits
Total number of fruits
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | test.census
stages <- c("seedling", "vegetative", "reproductive")
## Cross-tabulate stage vectors and order rows by stage
sv <- table(test.census$stage, test.census$year)[stages, ]
sv
stage.vector.plot(sv)
## set xaxt='n' to avoid fractions of a year (2002.5)
stage.vector.plot(sv, prop = FALSE, xaxt = "n", las = 1)
axis(1, 2001:2003, c(2001, 2002, 2003))
## Convert census data to state-fate transition table using reshape
reshape(test.census, direction = "wide", idvar = "plant", timevar = "year")
## Convert census data to state-fate transition table using merge
trans <- subset(
merge(test.census, test.census, by = "plant", sort = FALSE),
year.x == year.y - 1
)
trans
## Format column and row names
trans <- trans[, c(1:4, 6)]
colnames(trans)[2:5] <- c("year", "stage", "fruits", "fate")
rownames(trans) <- 1:nrow(trans)
## Order stage and fate columns
trans$stage <- ordered(trans$stage, levels = stages)
trans$fate <- ordered(trans$fate, levels = c(stages, "dead"))
## Select transitions for 2001-2002 and count offspring (seedlings)
trans01 <- subset(trans, year == 2001)
seedlings <- nrow(subset(test.census, year == 2002 & stage == "seedling"))
## Add individual fertilities using "anonymous reproduction" based on the
## proportional reproductive outputs of flowering plants and the total number
## of seedlings at the end of the projection interval
trans01$seedling <- trans01$fruits / sum(trans01$fruits) * seedlings
trans01
## Create transition frequency table and build T matrix
tf <- table(trans01$fate, trans01$stage)
tf
## remove "dead" fate from matrix
## T.mat<-prop.table(tf,2)[-4,]
T.mat <- prop.table(tf, 2)[stages, ]
T.mat
## Summarize stage-specific fertility rates and build F matrix
fert <- tapply(trans01$seedling, trans01$stage, mean)
fert
F.mat <- T.mat * 0
F.mat[1, ] <- fert
F.mat
## The final projection matrix is just
T.mat + F.mat
## OR use projection matrix function -
projection.matrix(trans01)
|
plant year stage fruits
1 1 2001 seedling 0
2 2 2001 seedling 0
3 3 2001 seedling 0
4 4 2001 seedling 0
5 5 2001 seedling 0
6 6 2001 seedling 0
7 7 2001 vegetative 0
8 8 2001 vegetative 0
9 9 2001 reproductive 2
10 10 2001 reproductive 4
11 11 2001 reproductive 9
12 1 2002 dead 0
13 2 2002 vegetative 0
14 3 2002 dead 0
15 4 2002 dead 0
16 5 2002 vegetative 0
17 6 2002 vegetative 0
18 7 2002 reproductive 2
19 8 2002 vegetative 0
20 9 2002 dead 0
21 10 2002 reproductive 7
22 11 2002 reproductive 3
23 12 2002 seedling 0
24 13 2002 seedling 0
25 14 2002 seedling 0
26 15 2002 seedling 0
27 16 2002 seedling 0
28 2 2003 vegetative 0
29 5 2003 dead 0
30 6 2003 vegetative 0
31 7 2003 vegetative 0
32 8 2003 dead 0
33 10 2003 dead 0
34 11 2003 dead 0
35 12 2003 dead 0
36 13 2003 dead 0
37 14 2003 dead 0
38 15 2003 vegetative 0
39 16 2003 dead 0
40 17 2003 seedling 0
41 18 2003 seedling 0
2001 2002 2003
seedling 6 5 2
vegetative 2 4 4
reproductive 3 3 0
plant stage.2001 fruits.2001 stage.2002 fruits.2002 stage.2003
1 1 seedling 0 dead 0 <NA>
2 2 seedling 0 vegetative 0 vegetative
3 3 seedling 0 dead 0 <NA>
4 4 seedling 0 dead 0 <NA>
5 5 seedling 0 vegetative 0 dead
6 6 seedling 0 vegetative 0 vegetative
7 7 vegetative 0 reproductive 2 vegetative
8 8 vegetative 0 vegetative 0 dead
9 9 reproductive 2 dead 0 <NA>
10 10 reproductive 4 reproductive 7 dead
11 11 reproductive 9 reproductive 3 dead
23 12 <NA> NA seedling 0 dead
24 13 <NA> NA seedling 0 dead
25 14 <NA> NA seedling 0 dead
26 15 <NA> NA seedling 0 vegetative
27 16 <NA> NA seedling 0 dead
40 17 <NA> NA <NA> NA seedling
41 18 <NA> NA <NA> NA seedling
fruits.2003
1 NA
2 0
3 NA
4 NA
5 0
6 0
7 0
8 0
9 NA
10 0
11 0
23 0
24 0
25 0
26 0
27 0
40 0
41 0
plant year.x stage.x fruits.x year.y stage.y fruits.y
2 1 2001 seedling 0 2002 dead 0
7 2 2001 seedling 0 2002 vegetative 0
12 2 2002 vegetative 0 2003 vegetative 0
16 3 2001 seedling 0 2002 dead 0
19 4 2001 seedling 0 2002 dead 0
24 5 2001 seedling 0 2002 vegetative 0
29 5 2002 vegetative 0 2003 dead 0
33 6 2001 seedling 0 2002 vegetative 0
38 6 2002 vegetative 0 2003 vegetative 0
42 7 2001 vegetative 0 2002 reproductive 2
47 7 2002 reproductive 2 2003 vegetative 0
51 8 2002 vegetative 0 2003 dead 0
52 8 2001 vegetative 0 2002 vegetative 0
59 9 2001 reproductive 2 2002 dead 0
63 10 2001 reproductive 4 2002 reproductive 7
67 10 2002 reproductive 7 2003 dead 0
72 11 2001 reproductive 9 2002 reproductive 3
76 11 2002 reproductive 3 2003 dead 0
81 12 2002 seedling 0 2003 dead 0
85 13 2002 seedling 0 2003 dead 0
89 14 2002 seedling 0 2003 dead 0
93 15 2002 seedling 0 2003 vegetative 0
97 16 2002 seedling 0 2003 dead 0
plant year stage fruits fate seedling
1 1 2001 seedling 0 dead 0.0000000
2 2 2001 seedling 0 vegetative 0.0000000
4 3 2001 seedling 0 dead 0.0000000
5 4 2001 seedling 0 dead 0.0000000
6 5 2001 seedling 0 vegetative 0.0000000
8 6 2001 seedling 0 vegetative 0.0000000
10 7 2001 vegetative 0 reproductive 0.0000000
13 8 2001 vegetative 0 vegetative 0.0000000
14 9 2001 reproductive 2 dead 0.6666667
15 10 2001 reproductive 4 reproductive 1.3333333
17 11 2001 reproductive 9 reproductive 3.0000000
seedling vegetative reproductive
seedling 0 0 0
vegetative 3 1 0
reproductive 0 1 2
dead 3 0 1
seedling vegetative reproductive
seedling 0.0000000 0.0000000 0.0000000
vegetative 0.5000000 0.5000000 0.0000000
reproductive 0.0000000 0.5000000 0.6666667
seedling vegetative reproductive
0.000000 0.000000 1.666667
seedling vegetative reproductive
seedling 0.000000 0.000000 1.666667
vegetative 0.000000 0.000000 0.000000
reproductive 0.000000 0.000000 0.000000
seedling vegetative reproductive
seedling 0.0000000 0.0000000 1.6666667
vegetative 0.5000000 0.5000000 0.0000000
reproductive 0.0000000 0.5000000 0.6666667
seedling vegetative reproductive
seedling 0.0000000 0.0000000 1.6666667
vegetative 0.5000000 0.5000000 0.0000000
reproductive 0.0000000 0.5000000 0.6666667
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.