Skip to content
Prev 378508 / 398502 Next

Recreate for loop without using for loop

Hi.



Can someone please help me recreate this code without using a for loop? Idk if I'm supposed to use a map function or something else.



qprob <- function(pp) {

  qq <- 1 - pp -1

  stotal <- 0.0

  for (i in 1:length(pp))

    stotal <- stotal + pp[i] * prod(qq[-i])

  return(stotal)

}

Best regards,
Rima


Sendt fra Mail<https://go.microsoft.com/fwlink/?LinkId=550986> til Windows 10