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

Robert Lowe ral64 at cam.ac.uk
Tue Jan 4 17:41:06 CET 2011


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


More information about the R-devel mailing list