Learn R Programming

PythonInR (version 0.1-12)

pyConnect: connects R to Python

Description

Connects R to Python. (The parameters are only needed for the Windows version!)

Usage

pyConnect(pythonExePath = NULL, dllDir = NULL, pythonHome = NULL)

pyConnectWinDll(dllName, dllDir, majorVersion, pythonHome, pyArch, useCstdout = NULL)

Arguments

pythonExePath

a character containing the path to "python.exe" (e.g. "C:\Python27\python.exe")

dllDir

an optional character giving the path to the dll file. Since the dll file is normally in a system folder or in the same location as python.exe, this parameter is almost never needed!

pythonHome

an optional character giving the path to PYTHONHOME. On Windows by default PYTHONHOME is the folder where python.exe is located, therefore this parameter is normally not needed.

dllName

a character giving the name of the dll file (e.g.d "python27.dll").

majorVersion

an integer giving the major Python version (e.g. 2 or 3).

pyArch

a character giving the Python architecture, i.e. "32bit" or "64bit".

useCstdout

a logical indicating if the C stdout should be used or the stout should be redirected at a Python level.

Details

There is a different behavior for the static (Linux default) and the explicit linked (Windows default) version. Where as the static linked version automatically connects, when the package get's loaded, the explicitly linked version needs to be connected manually. More information can be found at the README file or at http://pythoninr.bitbucket.org/.

Examples

Run this code
# NOT RUN {
## Linux examples
pyConnect() # is done by default when the package is loaded

## Windows examples
pyConnect() ## will try to detect a suitable python version 
            ## from the PATH given in the environment variables
pyConnect("C:\\Python27\\python.exe")

## One can also explicitly set the parameters for the connection.
PythonInR:::pyConnectWinDll(dllName="python27.dll", dllDir=NULL,
                            majorVersion=2, pythonHome="C:\\Python27", 
                            pyArch="32bit")
# }

Run the code above in your browser using DataLab