Re: [R] (no subject)

From: John Logsdon <>
Date: Tue 27 Dec 2005 - 21:43:44 EST

Is Barbara asking a much more basic question that is really RTFM?

Apart from the apply family of commands, the S language as implemented in R includes a lot of looping:

for (z in 0:m){

		cat("z non-zero\n")
		cat("z is zero\n")



z is zero

z non-zero
z non-zero
z non-zero

As Jacques points out, typing ?Control will give a good overview of the flow control features available, starting with:

if(cond) expr
if(cond) cons.expr else alt.expr

for(var in seq) expr
while(cond) expr
repeat expr

Following the links at the bottom of that help page will reveal the richness of R commands (it's easier if you use a browser for help).

I really suggest one of the excellent books on S/R such as MASS. After all, as many of these are written by R contributors, it is a way of making some small financial acknowledgement...:-)

Best wishes and Happy New Year to all


John Logsdon                               "Try to make things as simple
Quantex Research Ltd, Manchester UK         as possible but not simpler"    
+44(0)161 445 4951/G:+44(0)7717758675

On Tue, 27 Dec 2005, Jacques VESLOT wrote:

> ?Control
> but there are alternative ways :
> sapply(), apply(), lapply()...
> ifelse()
> etc.
> Barbora Kocúrová a écrit :
> >Hallo.
> >Could you please tell me if it is possible in R use something
> >like for-cycle or conditions with if and then.
> >I would need to index z from 0 to m and repeat some operations on each of them.
> >Could you please write me how can I do this?
> >Thank you very much
> >Barbora Kocurova
> >
> >______________________________________________
> > mailing list
> >
> >PLEASE do read the posting guide!
> >
> >
> >
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!
> mailing list PLEASE do read the posting guide! Received on Tue Dec 27 21:52:17 2005

This archive was generated by hypermail 2.1.8 : Tue 27 Dec 2005 - 23:54:11 EST