Hello,
I have just learnt some python, and would like to call R scripts from python, without 
using batch mode.
I learnt how to do it from perl, in fact reading in the mail archive I found the 
following good example: 

***************************************
#!/usr/local/bin/perl 
open (FILE, ">test.txt"); 
print FILE "a,b,c,d,e\n1,2,3,4,5"; 
close FILE; 

####### Start R code #### 
open (R_FH, "|/usr/local/bin/R --no-save --slave") or die "$!"; 

print R_FH qq{ 
data<-read.csv("test.txt") 
datamean<-mean(as.numeric(as.character(data[1,])), na.rm=TRUE) 
write(datamean, file="out.txt") 
quit(save='no',status=0) 
}; 

close R_FH; 
##### end R #### 

open(FILE, "<out.txt"); 
while (<FILE>){ 
$mean= $_; 
} 
close FILE; 
***************************************

this thankfully to the power of function open in perl.

I know this can be a bit OT, but is there a function in python accomplishing the same 
task?

Thanks to everyone.

G F


                                
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to