[R] Looping syntax?

Michaell Taylor pols1oh at bestweb.net
Fri Jun 29 19:26:10 CEST 2001



Sorry for what I hope is an unchallenging question for R veterans.

I have a question regarding looping syntax, though I know this should be 
avoided if possible in R - as in most other stat languages with which I am 
familiar.  

I would like to perform a series of operations on the subsets as defined by 
condition. Given the following data frame 

condition	X 	Y
aa		4	5
aa		8	9
.
.
bb		8	4
bb		3 	9
. 
. 
more ..

There are over 100 condition states, each with several hundred observations.  
For ease of this example, lets assume that I wish to make XY plots of each of 
the 100 condition states, with In other words, I need a structure like the 
following

for state in condition:
	identifier <- c("figure N:", cond)
	postscript(identifier,height=3,width=6,horizontal=F) 
	plot(X,Y, main=indentifier)
	n <- n+1

(Please excuse the bastardized R syntax, but not knowing the R syntax is the 
reason I am now writing)  The goal of this structure is to produce a graph 
for each unique value of condition which are sequentially numbered and 
entitled and saved with the condition state as part of the filename/title of 
the plot.

I know this must be simple in R, but the syntax is throwing me.  As an aside, 
could I get recommendations on the best S-Plus/ R book for data manipulation. 
 I have Venables & Ripley, "Modern Applied Statistics with S-Plus" and a 
smattering of web docs, but nothing seems to go into the details of indexing, 
built in fuctions, etc that seem pretty important.

Thanks in Advance.

Michaell Taylor

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list