i want to use a function for each row in a vector.
when I try my code I receive this message: the condition has length > 1 and only the first element will be used
function(Inn, x, y, z, xx, b, i, Dp){
if (Inn == 0) {
if (runif(1) <= x) { # success.probability.imitation
absorptive.capacity <- max(y, z)
}
else{
absorptive.capacity <- min(x, x + b/sqrt(i) - Dp)
}
} else{
if (runif(1) <= xx) { # sucess innovation
absorptive.capacity <- y + b / sqrt(i)
} else{
absorptive.capacity <- y + b / sqrt(i) - Dp
}
}
if (absorptive.capacity > 1) {
absorptive.capacity = 1
}
return(absorptive.capacity)
}
absorptive.capacity(c(0, 1), c(0.5, 0), c(0.7, 0.8), 0.7, c(0, 06), 0.5, c(64, 94), 0.06)
I want return each value after that transformation, this is the purpose for my function. Some one can help me?