Message-ID: <D48682E6-7D2E-4CA6-B0AA-3A4009220A91@dcn.davis.ca.us>
Date: 2019-02-11T04:23:28Z
From: Jeff Newmiller
Subject: Recreate for loop without using for loop
In-Reply-To: <VI1PR0301MB2207439A81621C7457601AA0F06B0@VI1PR0301MB2207.eurprd03.prod.outlook.com>
There is a no-homework policy stated in the Posting Guide.
On February 10, 2019 8:59:41 AM PST, Rima El-zein <Rima.ec at hotmail.com> wrote:
>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
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
Sent from my phone. Please excuse my brevity.