Initialization at Start of an R Session on Windows
The following explains how to setup an
.Rprofile file at Windows with a special focus on PythonInR, a general documentation can be found here
Where is my HOME Folder?
The home directory is normally set to
C:\Users\username\Documents and can be obtained by typing
Set Persistent Environment Variables
To set persistent environment variables on Windows the file
.Renviron can be utilized.
Just create a file with the name
.Renviron in your home folder.
NOTE: Renaming a existing file to
.Renviron didn't work for me since Windows complained that I should enter a file name. But saving a file from a text editor as
.Renviron did work.
python.exe file is located at
C:/Python27/python.exe you should put the following into your
Or for those who prefer to not leave their R terminal.
envFile <- file.path(Sys.getenv("R_USER"), ".Renviron") x <- if (file.exists(envFile)) readLines(envFile) else character() x <- unique(c(x, 'PYTHON_EXE=C:/Python27/python.exe')) writeLines(x, envFile)
.Rprofile can be used to execute R code at the startup. Therefore it can also be used to set environment variables. Just put
.Rprofilefile to get the same effect as with
.Renviron. More information can be found here.