Skip to content
Prev 74877 / 398502 Next

help regarding loops in R

Rangesh Kunnavakkam wrote:
Each element of what? lambda (sic), k? What are these? vectors, scalars? 
R is vectorised, so you should be able to do following, assuming lambda 
is a vector and k is a scalar, for example:

p <- 1 - exp(k * exp(-lambda))

(I am assuming I parsed your formula correctly. If not, please do clarify.)

If both k and lambda are both vectors then the above still applies as 
long as they are the same length (including length 1). If they differ in 
length, beware of R's recycling rules.

HTH,

--sundar

P.S. Have you read the posting guide and subsequent literature, 
especially, an Introduction to R? Because you used "exp^(...)" and 
"kexp" suggests, no.