Skip to content

Instantly share code, notes, and snippets.

@lindenb
Created March 30, 2010 11:43
Show Gist options
  • Save lindenb/349031 to your computer and use it in GitHub Desktop.
Save lindenb/349031 to your computer and use it in GitHub Desktop.
/* C call from R
.Call("myroundCall",as.double(1204.245))
*/
SEXP myroundCall(SEXP a){
double *ap = REAL(a), *ansp;
SEXP ans;
PROTECT(ans = allocVector(REALSXP, 1));
ansp = REAL(ans);
*ansp = Rf_fround(*ap,2);
UNPROTECT(1);
return(ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment