As others have said, no need for a loop Another approach mydata <- data.frame(A = dpois(x,exp(4.5355343)), B = dpois(x,exp(4.5355343 + 0.0118638)), C = dpois(x,exp(4.5355343 -0.0234615)), D = dpois(x,exp(4.5355343 + 0.0316557)), E = dpois(x,exp(4.5355343 + 0.0004716)), F = dpois(x,exp(4.5355343 + 0.056437)), G = dpois(x,exp(4.5355343 + 0.1225822)))
df1 <- rowSums(mydata) plot(df1) --- On Mon, 11/14/11, Davg <davidgrim...@hotmail.com> wrote: > From: Davg <davidgrim...@hotmail.com> > Subject: [R] Very simple loop > To: r-help@r-project.org > Received: Monday, November 14, 2011, 10:59 AM > I'm very new to R and am trying to > create my first loop. > > I have: > > x <-c(0:200) > A <- dpois(x,exp(4.5355343)) > B <- dpois(x,exp(4.5355343 + 0.0118638)) > C <- dpois(x,exp(4.5355343 -0.0234615)) > D <- dpois(x,exp(4.5355343 + 0.0316557)) > E <- dpois(x,exp(4.5355343 + 0.0004716)) > F <- dpois(x,exp(4.5355343 + 0.056437)) > G <- dpois(x,exp(4.5355343 + 0.1225822)) > > and would like to to get A[K] + B[K] + C[K] + D[K] + E[K] + > F[K] G[K] > for K(0:200) > > And then plot these cumulative values. > > Many thanks. > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Very-simple-loop-tp4039895p4039895.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org > mailing list > 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. > ______________________________________________ R-help@r-project.org mailing list 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.