I am writing a code in R but it reports the following error:
In if ((BWGmax * (1 - exp (-K * (MCisimulate - Xm))))> WG) {: the condition has length > 1 and only the first element will be used.
Can you help me?
BWGmax <- 30
K <- 0.0118
Xm <- 21
SD <- 0.851636356306513
number <- 420
mean <- 28
MCic <- seq(from = 200, to = 270, by = 1.7)
MCisimulate <- rep(MCic, number)
WG <- c()
for(i in 1:number) { WG[i] <- ((sqrt(-2*log(runif(1, 0, 1)))*sin(2*pi*runif(1, 0, 1)))*SD)+(mean)} #mudar depois numeros por parametros
BW <- 0.0223*WG^0.8944
BWG <- if ((BWGmax*(1-exp(-K*(MCisimulate-Xm)))) > WG) { WG } else { (BWGmax*(1-exp(-K*(MCisimulate-Xm)))) }
BWG