[R] Display execution in a function

Sebastien Durand sebastien.durand at umontreal.ca
Fri Apr 15 17:15:02 CEST 2005


Based on what Jim say yes it works, but if we 
look at the following function, which I beleive 
is properly written.

#############
area.select2<-function(nav,width=6,height=6,...){
	par(ask=TRUE)
	cat("Please select first two opposite 
corner of the working area","\n");
	plot(x=nav[,1],y=nav[,2],"l",col="blue");
	points=locator(2);
	ok<-0;
	while(ok!=1){
		cat("Is your selection correct: YES =1 or NO=0","\n");
		rect(xleft=min(points$x), 
ybottom=min(points$y), xright=max(points$x), 
ytop=max(points$y), density = 0,col = "red", 
border = TRUE);
		ok<-scan("",nlines=1,quiet=TRUE);
		if(ok!=1){
			cat("Please reselect your points","\n");
			points<-locator(2);
		}else{}
	}
	return(points);
}
#############

When run,  using the following call:
#############
area.select(nav=matrix(1:20,10,2))
#############

Even so the text output 'cat("Please reselect 
your points","\n")'  was written previously to 
'points<-locator(2)' , the text does not appears 
at the correct time when I try to select a new 
area.


I really don't understand what is going on there! 
Isn't suppose to be what is written first shall 
happen first!
Could this phenomenon be cause by the locator function...

Cheers!

Sébastien

>Sebastien Durand wrote:
>>Dear all I hope you haven't received this message twice,
>>
>>Here is a simplified version of a function I made:
...snip...
>Setting par(ask=TRUE) before the plot command 
>will require the user to press Enter before the 
>plot is displayed.
>
>Jim


-- 
  Sébastien Durand
Maîtrise en biologie
Université de Montréal
(514) 343-6864
Université du Québec à Montréal
(514) 987-3000 (1572#)




More information about the R-help mailing list