[Tutor] Subprocess module

Judith Flores juryef at yahoo.com
Wed Nov 26 20:51:13 CET 2008


Hello,

   A couple of weeks ago I posted a question about what documentation I should read in order to implement a way to communicate Python and R. I read about the module 'subprocess', but have not been able to do something very simple. I was wondering if you could tell me how to transfer a Python variable to R. For example, a variable called 'fileforR'  will acquire a pathfile from the user through a GUI. This file will be a csv file that will be processed in a R script for statistical analysis. Let's suppose the R script is called: 'read_file.R', and that it contains the following code:

read.csv(fileforR)
q()

In the Python interpreter:

import easygui
import subprocess

fileforR = fileopenbox()

After this, I have tried different combinations to try to call R and the mentioned R script, for example:

subprocess.call('R')

opens the R console, but I can't access the R script. And there's another problem I can't solve: passing the 'fileforR' variable from Python to the R environment.


   I am working on SUSE Linux, and using Python 2.5.2.


Thank you very much,

Judith


      


More information about the Tutor mailing list