From ral64 at cam.ac.uk  Tue Jan  4 17:41:06 2011
From: ral64 at cam.ac.uk (Robert Lowe)
Date: Tue, 4 Jan 2011 16:41:06 +0000
Subject: [Rd] C code hanging and printing everything at the end
References: <DA930DC9-8A65-422A-8668-491236CD4952@cam.ac.uk>
Message-ID: <64F9E9B1-2FF8-43FF-A1F8-4CB1E612A1A9@cam.ac.uk>

Hi,

I am currently writing an extension for R and have the need to include some C code. If I call the code with a large amount of data then it can take several minutes to complete.

The C code prints out after a certain iteration hence letting the user know it hasn't crashed.

When running in R this generally does not happen and all is printed out at the end once the program has completed successfully.

I am using Rprintf() to print out the required output.

e.g. Something simple which illustrates my point

for(int i=0; i<10000; i++){
	#Calculations
	if (i%1000==0){
		Rprintf("Step %d\n",i)
	}
}

All I get during the program is the OS X spinning wheel in R. Is there any way to print out as the program is running?

Thanks,
Rob


[Rd] C code hanging and printing everything at the end
Robert Lowe