How can I convert the jupyter R magics like %%R or %Rpush or %Rpull or the execution of an R function into a regular python script?
1 Answer
The answer is partly in the comments above:
http://rpy2.readthedocs.io/en/version_2.8.x/introduction.html#creating-rpy2-vectors here is a nice and longer explanation
This is the solution to the last mentioned problem of implementing a %Rpush robjects.IntVector([1, 2, 3])
subprocessto call the script. This question suggests usingrpy2withr.source("script.R")process = subprocess.Popen(['R', '--vanilla', '--args', '\\%s_DM_Instances_R.csv\\' % output_filename, '<', '/home/kevin/AV-labels/Results/R/hierarchical_clustering.R'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) process.communicate()#[0] is stdoutbut how whould %Rpush / %Rpull work?