s-news
[Top] [All Lists]

Re: iterationsinlooping

To: Gerald E Bove Jr <gebove@geog.buffalo.edu>
Subject: Re: iterationsinlooping
From: Spencer Graves <spencer.graves@pdf.com>
Date: Tue, 21 Oct 2003 01:49:05 -0700
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <Pine.GSO.4.05.10310202146340.27537-100000@alice.geog.buffalo.edu>
References: <Pine.GSO.4.05.10310202146340.27537-100000@alice.geog.buffalo.edu>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
The "for" loop syntax is as follows:
     for(index in set){ statement(s) }

Example:
     for(i in 1:2)print(i)

Please see "help('for')", or any good basic reference on S, S-Plus or R, e.g., the "for" loops in the on-line Programmer's Guide. There are also many other documents describing the language downloadable, e.g., from "www.r-project.org". I highly recommend Venables and Ripley (2002) Modern Applied statistics with S, 4th ed. (Springer).
hope this helps.  spencer graves

Gerald E Bove Jr wrote:

when i create a loop to test cases in a particular column in a matrix why
does it loop for only one iteration even though test condition is not met? ex. for (i in fp[,2]) if (condition) (assignment)
have tried several variations on first part of expression but always get
same result, won't loop past first iteration, is my for statement bad? how
can i search a particular column of data, test cases, save results, test
next column with new condition then total over 3rd column based on first 2
results.  Not to difficult a program if loop would work.
thanks

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


<Prev in Thread] Current Thread [Next in Thread>