Executing an R script in python via subprocess.Popen

前端 未结 5 546
逝去的感伤
逝去的感伤 2021-01-20 23:25

When I execute the script in R, it is:

$ R --vanilla --args test_matrix.csv < hierarchical_clustering.R > out.txt

In Python, it works if

5条回答
  •  旧时难觅i
    2021-01-21 00:15

    I've solved this problem by putting everything into the brackets..

    process = subprocess.Popen(["R --vanilla --args "+output_filename+"_DM_Instances_R.csv < /home/kevin/AV-labels/Results/R/hierarchical_clustering.R > "+output_filename+"_out.txt"], shell=True)
    process.wait()
    

提交回复
热议问题