全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1687 1
2009-08-28
On page 276 of the R book, when I run the following code with R2.9.2

phmodel <-function(t, x, parms) {
v<-x[1]
n<-x[2]
with(as.list(parms),{
dv=r*v*(K-v)/K - b*v*n
dn=c*v*n – d*n
res<-c(dv,dn)
list(res)
})}
times <-seq(0, 500, length=501)
parms <-c(r=0.4, K=1000, b=0.02, c=0.01, d=0.3)
y<-xstart <-c(v=50, n=10)
output <-as.data.frame(rk4(xstart, times, phmodel, parms))
plot (output$time, output$v,ylim=c(0,60),type="n",ylab="abundance",xlab="time")
lines (output$time, output$v)
lines (output$time, output$n,lty=2)

I got the following error message:

Error: unexpected input in:
"dv=r*v*(K-v)/K - b*v*n
dn=c*v*n –"
> res<-c(dv,dn)
Error: object 'dv' not found
> list(res)
Error: object 'res' not found

Any help will be appreciated!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-1-26 15:57:14
dv=r*v*(K-v)/K - b*v*n
dn=c*v*n d*n
  
你仔细看这两个公式,减号有一个是不对的,
所以后面的都读不出来
要list一个读不出来的res肯定就报错了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群