[R] Run a Python code from R

Robert Baer rbaer at atsu.edu
Sun Nov 20 01:05:13 CET 2016


 From https://www.r-bloggers.com/rpithon-vs-rpython/

<https://www.r-bloggers.com/rpithon-vs-rpython/>"Similar to rPython, the 
rPithon package (http://rpithon.r-forge.r-project.org) allows users to 
execute Python code from R and exchange the data between Python and R. 
However, the underlying mechanisms between these two packages are 
fundamentally different. Wihle rPithon communicates with Python from R 
through pipes, rPython accomplishes the same task with json. A major 
advantage of rPithon over rPython is that multiple Python processes can 
be started within a R session. However, rPithon is not very robust while 
exchanging large data objects between R and Python."


On 11/16/2016 7:10 PM, David Winsemius wrote:
>> On Nov 16, 2016, at 4:53 PM, Nelly Reduan <nell.redu at hotmail.fr> wrote:
>>
>> Thank you very much for your help !
>>
>>
>> I 'm trying to use the package "rPithon" but I obtain this error message:
> Are you sure you are not just misspelling rPython? If that's not the issue than you need to say where you got rPithon,

 From https://www.r-bloggers.com/rpithon-vs-rpython/

"Similar to rPython, the rPithon package 
(http://rpithon.r-forge.r-project.org) allows users to execute Python 
code from R and exchange the data between Python and R. However, the 
underlying mechanisms between these two packages are fundamentally 
different. While rPithon communicates with Python from R through pipes, 
rPython accomplishes the same task with json. A major advantage of 
rPithon over rPython is that multiple Python processes can be started 
within a R session. However, rPithon is not very robust while exchanging 
large data objects between R and Python."


>> On Wed, Nov 16, 2016 at 4:53 PM, Nelly Reduan <nell.redu at hotmail.fr> wrote:
>>> Hello,
>>>
>>>
>>> How can I run this Python code from R ?
>>>
>>>
>>>>>> import nlmpy
>>>>>> nlm = nlmpy.mpd(nRow=50, nCol=50, h=0.75)
>>>>>> nlmpy.exportASCIIGrid("raster.asc", nlm)
>>>
>>> Nlmpy is a Python package to build neutral landscape models
>>>
>>> https://pypi.python.org/pypi/nlmpy . The example comes from this website. I tried to use the function system2 but I don't know how to use it.
>>>
>>>
>>> path_script_python <- "C:/Users/Anaconda2/Lib/site-packages/nlmpy/nlmpy.py"
>>>
>>> test <- system2("python", args = c(path_script_python, as.character(nRow), as.character(nCol), as.character(h)))
>>>
>>> Thanks a lot for your help.
>>> Nell
>>>
>>>
>>> nlmpy 0.1.3 : Python Package Index<https://pypi.python.org/pypi/nlmpy>
>>> pypi.python.org
>>> NLMpy. NLMpy is a Python package for the creation of neutral landscape models that are widely used in the modelling of ecological patterns and processes across ...
>>>
>>>
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>>
>>> David Winsemius
>>> Alameda, CA, USA
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.


	[[alternative HTML version deleted]]



More information about the R-help mailing list