cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
DMR
DMR
Level V

Setting the R_HOME environment variable for different users

Hi,

I have a JSL script that's calling an R routine.  To run it, I'm setting an environment variable called R_HOME to the location into which R (currently version 3.2.2) has been installed.  The syntax is:

Set Environment Variable("R_HOME", "C:\whatever the path is on my laptop\R-3.2.2");

Everything works; no problem.  However, I need to deploy this script to a number of other users, each of whom could well have (a) put the R package somewhere else, and (b) installed it under a different name - most obviously if a new version of R is released, and they install it with the default name of the new version number.  It seems to me this presents me with a problem, because I don't know what to set the R_HOME environment variable to for anyone else but me.

Is there any way I can search for the most recent version of R - whatever it is - on the other users' machines, and then set the environment variable accordingly?  Or will I have to insist that every user gives their R directory exactly the same name, and to put it in a specific location which I specify?

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Setting the R_HOME environment variable for different users

JMP should automatically find the R_HOME environment variable.  The following is taken from the JMP Scripting Guide

How JMP Finds R

JMP delays loading R until a JSL-based script requires access to it. When JMP needs to load R, it follows the standard steps for finding R on a Windows computer: 1. Look up the environment variable R_HOME. If the variable exists, load R from the specified directory. 2. If the environment variable R_HOME does not exist, look up the InstallPath value in the Windows registry under the following key: HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R For 32-bit JMP running on a 64-bit machine, the InstallPath value is under the following key: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NODE\R-core\R If the InstallPath value exists, load R from the specified directory. 3. If the InstallPath value does not exist, an error message states that R could not be found.

If R is installed correctly, it will set the R_HOME environment variable, so your colleagues should not have an issue running your script, as long as you don't override the R_HOME environment variable.

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Setting the R_HOME environment variable for different users

JMP should automatically find the R_HOME environment variable.  The following is taken from the JMP Scripting Guide

How JMP Finds R

JMP delays loading R until a JSL-based script requires access to it. When JMP needs to load R, it follows the standard steps for finding R on a Windows computer: 1. Look up the environment variable R_HOME. If the variable exists, load R from the specified directory. 2. If the environment variable R_HOME does not exist, look up the InstallPath value in the Windows registry under the following key: HKEY_LOCAL_MACHINE\SOFTWARE\R-core\R For 32-bit JMP running on a 64-bit machine, the InstallPath value is under the following key: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NODE\R-core\R If the InstallPath value exists, load R from the specified directory. 3. If the InstallPath value does not exist, an error message states that R could not be found.

If R is installed correctly, it will set the R_HOME environment variable, so your colleagues should not have an issue running your script, as long as you don't override the R_HOME environment variable.

Jim
DMR
DMR
Level V

Re: Setting the R_HOME environment variable for different users

Thanks Jim - it looks like this particular problem is simply going to vanish when the time comes to deploy it, which is great news.

Many thanks,

David