Skip to content
Prev 4062 / 398506 Next

R question

On Thu, Dec 16, 1999 at 02:41:25PM -0500, Faheem Mitha wrote:
Subsetting in S (and hence R) uses [] for subsetting.  What you need is

	x <- 0
	for(i in 1:10) x <- x + l[i]

(If the values are really in a vector, x <- sum(l) is rather faster).

	Ross
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Message-ID: <19991217074917.A19111@stat1.stat.auckland.ac.nz>
In-Reply-To: <Pine.LNX.4.10.9912161430460.708-100000@Chrestomanci.home.earth>; from Faheem Mitha on Thu, Dec 16, 1999 at 02:41:25PM -0500