# error "Non numeric argument to binary operator"

Hello,
I'm getting the error "Non numeric argument to binary operator" with this code :

``````SDO <- function(t,state,parms)
{
with(as.list(c(state,parms)),
{
a=parms[1]; b= parms[2];c=parms[3];d=parms[4]; b_1= parms[5]; b_2= parms[6]; b_3= parms[7]
R = state["R"] ; S=as.numeric(state["S"])
dR <- a-d*((S/b)^c/(1+(S/b)^c)) - b_1*R
dS <- b_2*R - b_3*S
return(list(c(dR, dS)))
}
)
}
a=3
b=2
c=1.5
d=1
b_1 = 1
b_2 = 2
b_3 = 3

parameters = list(a=a, b=b, c=c,d=d, b_1=b_1, b_2=b_2, b_3=b_3)
R0 = 30
S0 = 10
#
yini <- c(R=R0,S=S0) # Point de depart
#
times <- seq(0,0.5,by=0.0001)
out <- ode(y=yini,times=times,func=SDO,parms=parameters,method="lsoda")
``````

` Error in S/b : argument non numérique pour un opérateur binaire`

Where is the problem ?

``````  a=parms[1]; b= parms[2];c=parms[3];d=parms[4]; b_1= parms[5]; b_2= parms[6]; b_3= parms[7]
``````

should be

``````  a=parms[[1]]; b= parms[[2]];c=parms[[3]];d=parms[[4]]; b_1= parms[[5]]; b_2= parms[[6]]; b_3= parms[[7]]
``````

to fully unpack from list, otherwise you will be doing arithmetic on lists rathers than numerics

Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Thank you

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