modeling of two subpopulation

Hi!!!

I have problems with my code. I already create a function to modeling the the grow of two subpopulations. The problem is that the data.frame that my function return is empty. Here is my code

#parameters

K=1000000
r=0.1
Rn=-0.1
Rm=0.05
n0=99
m0=1
time=300
n<-numeric(length = time)
m<-numeric(length = time)
n[1]=n0
m[1]=m0

cancer <- function(n0=99, m0=1, r=0.1, Rn=-0.1, Rm=0.05, K=1000000, time=300){
n<-numeric(length = time)
m<-numeric(length = time)
n[1]=n0
m[1]=m0

for(t in 1:(time-1)){
if(t < 150){
n[t+1]=n[t]+rn[t](1-((n[t]+m[t])/K))
m[t+1]=m[t]+rm[t](1-((n[t]+m[t])/K))
}
else(t > 150)
{
n[t+1]=n[t]+Rnn[t](1-((n[t]+m[t])/K))
m[t+1]=m[t]+Rmm[t](1-((n[t]+m[t])/K))
}
return(data.frame(n,m))
}
}

PlotCancer <- cancer()
PlotCancer$time = 1:nrow(PlotCancer)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.