* [[en:ecovirt:roteiro:sucess:tradeoff|{{:ecovirt:logorcmdr01.png?20|}}]] * [[en:ecovirt:roteiro:sucess:tradeoffr|{{:ecovirt:rlogo.png?20|}}]] ====== Conflicting demands - Tutorial in R ====== {{section>en:ecovirt:roteiro:sucess:tradeoff_base#conflicting_demands}} === Trade-off in R === {{section>en:ecovirt:roteiro:avisos#roteiro_r}} First, open R and let's make a graph of this scenario of abundances for 10 species with the proportion of occupied patches for the best competitor in 20%: x11() # open a window for the graph s=10 # number of species in the begining of the simulation i=1:s # position of the species in competition i d=0.2 # number of occupied patches for the best competitor species p=d*(1-d)^(i-1) # Proportion of occupied patches for each species in equilibrium p plot(i, p, type="b", ylab="Proportion of occupied patches", xlab="Species rank") Let's add the colonization rates in our graph, calculating for a constant extinction rate in 0.04 for all species: pe=0.04 c= pe/(1-d)^(2*i-1) c par(mfrow=c(1,2)) plot(i, p, type="b", ylab="Proportional abundancees", xlab="Species rank") plot(i, c, type="b", col="red", ylab="Colonization rate", xlab="Species rank" ) This is our equilibrium,a geometric distribution of abundances with the most abundant species with 20% and an extinction rate of 4% for all species. ===== The model ===== {{section>en:ecovirt:roteiro:sucess:tradeoff_base#the_model}} {{section>en:ecovirt:roteiro:avisos#roteiro_r}} Utilize a função **comCompete** do pacote EcoVirtual no R. ==== Simulation parameters ==== {{section>en:ecovirt:roteiro:sucess:tradeoff_base#argumentos}} ===== Testing the model ===== {{section>en:ecovirt:roteiro:sucess:tradeoff_base#testing_the_model}} ===== Including disturbance ===== {{section>en:ecovirt:roteiro:sucess:tradeoff_base#including_disturbance}} Save each simulation with a different object name. In the examples above we did that by calling each simulation by a name (test1, test2 ...) to the right hand of the <- symbol, see below: teste5 <- com.compete(tf=1000,l=100,c=100, s=10, fi=0.2, d=0.2, pe=0.04, fr=10, int=0.2) This way, the result of the simulation is saved on different objects and we can then use these results. For example, we may be interested in seeing what the most abundant species is at the end of the simulation, for example in the last 10 cycles: tf5=dim(teste5)[2] teste5[,(tf5-10):tf5] We can also count the number of species over time, as: apply(teste2>0, 2, sum) If you want to perform any other operation with the simulated data, contact the teacher. ===== To learn more===== {{section>en:ecovirt:roteiro:sucess:tradeoff_base#to_learn_more}} {{tag>R multipopulações comunidades competição disturbio sucessão}}