# NOT RUN {
# Define the community
species1 = list(2.5, matrix(c(25, 100)), matrix(data=c(9, 60,
60, 625), nrow=2, ncol=2, byrow=TRUE))
species2 = list(5.0, matrix(c(28, 110)), matrix(data=c(4, -20,
-20, 500), nrow=2, ncol=2, byrow=TRUE))
species3 = list(3.0, matrix(c(25, 80)), matrix(data=c(4, 0,
0, 150), nrow=2, ncol=2, byrow=TRUE))
community = list(species1, species2, species3)
# Define the interactions
interactions = matrix(data=c(0.0, 0.2,-0.4,
-1.0, 0.0,-1.0,
-0.6, 0.3, 0.0), nrow=3, ncol=3, byrow = TRUE)
# Calculate the realised niche values
niche.XY = niche.grid.coords(mins=c(15,0), maxs=c(35,200), nCoords=121)
realNiche = real.niche(niche.XY, community, interactions)
# Plot the realised niche for species 1
realNiche1 = matrix(realNiche[,1], nrow=length(unique(niche.XY[,1])))
nContour = 10
filled.contour(unique(niche.XY[,1]), unique(niche.XY[,2]), realNiche1,
levels = seq(0, 5, 5/nContour),
col=colorRampPalette(c("gold", "firebrick"))(nContour),
xlab=expression(paste("Temperature (", degree, "C)")),
ylab="Rainfall (mm)",
main ="Realised niche",
key.title = title(main = expression(lambda)))
# }
Run the code above in your browser using DataLab