[R] Rprintf not updating

blosloos Martin.Loos at eawag.ch
Tue May 20 15:59:25 CEST 2014


Hi

Could not make this example work, maybe because its missing
*rPercentComplete pointing at percentComplete. The above mentioned link has
been moved? to:
https://gist.github.com/KRD1/2503984

however, this worked for me:

*R side:*

/pBar <- txtProgressBar( min = 0, max = 100, style = 3)
blub<-.Call("FUBAR", 
		as.matrix(blab),
		as.matrix(blib),		
	        ...,
		pBar,
		PACKAGE="blob"
)	
close(pBar)/


*C side:*
/  
...
extern "C"{

SEXP FUBAR(
    SEXP blab,
    SEXP blib,
    ...,
   SEXP pBar
){

   ...

   SEXP utilsPackage; 
   PROTECT(utilsPackage = eval(lang2(install("getNamespace"),
ScalarString(mkChar("utils"))),R_GlobalEnv));
   SEXP percentComplete;
   PROTECT(percentComplete = NEW_NUMERIC(1));
   double *rPercentComplete;
   rPercentComplete = NUMERIC_POINTER(percentComplete);


   for(some loop on n){
       *rPercentComplete = n;
        eval(lang4(install("setTxtProgressBar"), pBar, percentComplete,
R_NilValue), utilsPackage);
   }


   UNPROTECT(...)
   return ...
}

}/



--
View this message in context: http://r.789695.n4.nabble.com/Rprintf-not-updating-tp1751703p4690887.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list