[Rcpp-devel] how to get rid of the warning message: no graphics system to unregister

Haiying Pang haiyingwithu at gmail.com
Mon Feb 13 20:26:21 CET 2012


Here is the test code I first used to call the R function from C++ program.
At the end, the warning message came out.

double two_sample_logrank(RInside R, double* t, int* d, int sample_size)
{
double p_val = 0;
int n = 2*sample_size;
std::string txt =                   // load library, run regression, create
summary
        "suppressMessages(require(splines));"
"suppressMessages(require(survival))";
R.parseEvalQ(txt);                  // eval command, no return

double* g = new double[n];
int i = 0;
for(i=0; i<sample_size; i++) g[i] = 1;
for(i=sample_size; i<n; i++) g[i] = 2;
 /* construct vectors used in R from double* and int* */
std::vector<double> std_t(t, &t[n]);
R["t"] = std_t;
std::vector<int> std_d(d, &d[n]);
R["d"] = std_d;
std::vector<int> std_g(g, &g[n]);
R["g"] = std_g;

txt = "df <- data.frame(t,d,g);"
"cat('Showing df\n'); print(df); "
"sdf <- survdiff(Surv(t,d)~as.factor(g), data=df);"
"cat('Showing sdf\n'); print(sdf); "
"p.val <- 1 - pchisq(sdf$chisq, length(sdf$n) - 1);"
"trend <- (sdf$obs - sdf$exp)<0;"
"if (trend[2]==FALSE) {p.val <- 0.9999};"
"p.val"; //return the p.val of survdiff
p_val = R.parseEval(txt);

delete [] g;
return p_val;
}

int main(int argc, char* argv[]){
printf("get in\n");

RInside R(argc, argv);
 double t[] = {1.0, 2.0, 3, 0.3, 4, 0.9, 5, 8.9, 10, 0.5};
int d[] = {1, 1, 0, 0, 0, 1, 0, 1, 0, 1};
 int sample_size = 5;
double p_val = 0.0;
 p_val = two_sample_logrank(R, t, d, sample_size);
printf("get out with %2.4f\n:", p_val);
}




On Sat, Feb 11, 2012 at 12:28 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 10 February 2012 at 16:57, Haiying Pang wrote:
> |
> | I am calling a R function through Rcpp and RInside in my c++ program in
> Linux.
> | There are a lot of warning messages saying "no graphics system to
> unregister"
> | that were outputed to my log file, which leaded to a hug log file that I
> can
> | hardly open after letting the code run for a few hours. Is there anyone
> who
> | knows the reason and how to avoid the printing of such warning messages?
> I
> | appreciate for your help!
>
> Without a minimal reproducible example, nobody is going to be able to help
> you.
>
> Dirk
>
> --
> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is
> too
> dark to read." -- Groucho Marx
>



-- 
Haiying Pang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120213/03801c48/attachment.html>


More information about the Rcpp-devel mailing list