Posted by
Thomas Boudier on
URL: http://imagej.273.s1.nabble.com/IJ-R-tp3698793p3698796.html
I do everything by files, create input files to R into IJ, R creates
output files that I read in IJ. U can also try to "read" R output text
with something like this :
Process p = ....;
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String str;
while ((str = br.readLine()) != null) {
System.out.println(str);
}
is.close();
// Wait for the process to complete.
int status = -1;
try {
status = p.waitFor();
} catch (InterruptedException e) {System.out.println(e);}
} catch (java.io.IOException e) {System.out.println("error " + e);
}
Hope this helps
Thomas
Gabriel Landini a écrit :
> On Friday 20 July 2007 08:35:13 Thomas Boudier wrote:
>> Hi Gabriel,
>>
>> I have tested launching R scripts from ImageJ, here is how to do it :
>>
>> String cmd = ""R CMD BATCH path_to_your_R_script.R"
>> Process p = Runtime.getRuntime().exec(cmd);
>>
>> That should work
>
> That is great. Thank you.
> Is there any way of getting R results back into IJ? Or it is only a one way
> route?
>
> Cheers,
>
> Gabriel
>
>
--
/*****************************************************/
Thomas Boudier, MCU Université Paris 6,
UMR 7101 / IFR 83. Bat A 328, Jussieu.
Tel : 01 44 27 35 78 Fax : 01 44 27 25 08
/****************************************************/