I try to track down an error in a R-script that does call a C++ program. The R tells me, that my C++ returned NA - but that does not seems to be the case when I look through the program. There is nothing called that would result in NA in R. Hence my question, if R may never capture the output from the C++ program, because return 0
is called before all output has been written to the console.
My program does writes some numbers to the console. One number per line, the last line ends with endl
.
main()
{
cout<<33.12<<"\n"; //print a couple of number to cout
cout<<9711.3<<"\n"<<5699.14<<endl;
return 0;
}
My R-Script does stuff like this:
x <- as.numeric(system("./myProgram", intern=T))
if(any(is.na(x))) {
stop("Wooppp, x is NA: ", x)
}
Can it be, that R does not get the cout-output from by program? This question is related to the corresponding R-question: DEOptim keeps telling: NaN value of objective function