call python with system() in R to run a python script emulating the python console
Posted
by
Yihui
on Stack Overflow
See other posts from Stack Overflow
or by Yihui
Published on 2012-04-14T17:25:28Z
Indexed on
2012/04/14
17:29 UTC
Read the original article
Hit count: 1737
I want to pass a chunk of Python code to Python in R with something like system('python ...'), and I'm wondering if there is an easy way to emulate the python console in this case. For example, suppose the code is "print 'hello world'", how can I get the output like this in R?
>>> print 'hello world'
hello world
This only shows the output:
> system("python -c 'print \"hello world\"'")
hello world
Thanks!
BTW, I asked in r-help but have not got a response yet (if I do, I'll post the answer here).
© Stack Overflow or respective owner