Hi mmaccora,
First let me clarify what the R working directory and workspace mean. The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions). At the end of an R session, the user can save an image of the current workspace to a location on the file system, the "working directory", and it will automatically reload the next time R is started. SAS Enterprise Miner's Open Source Integration (OSI) node sets the R working directory to a temporary file, just the same as SAS creates a SAS working directory for each SAS session. These are temporary files that disappear after the session ends. If you turn on options mprint in the project start code and rerun the node, you will see where the OSI node sets the working directory:
NOTE: %INCLUDE (level 1) file _RSUBMIT is file C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2\RSUBMIT.sas.
24560 +_WORK_DIR= "%sysfunc(getoption(work))";
MPRINT(EM_OPEN_TRAIN): _WORK_DIR= "C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2";
We don't recommend changing the work directory, but if you do decide to change it, make sure you have read and write permissions to that location and the location exists.
To answer your original question regarding installation directory and how that works:
In the picture you sent in of the OSI node log, it looks like you are trying to set the working directory for R to tell the OSI node where the libraries are located. You don't need to do this. When you install an R package, the packages install to the location you included in setwd("C:/Program Files/R/R-3.2.5/library"). After they are installed in R, you do not need to point to this location again, even in the OSI node. You simply need to call the library you want to use. The only code you would need to put in the code editor would be:
library(DMwR) &EMR_EXPORT_TRAIN <- SMOTE(form = &EMR_CLASS_TARGET ~ &EMR_CLASS_INPUT + &EMR_NUM_INPUT, data = &EMR_IMPORT_DATA, perc.over = 200, k = 5, perc.under = 1000)
Enterprise Miner passes the code back to R to run, and R already knows where to find these packages. Your code should run successfully without the setwd() command.
I hope this helps!
Jess Mayo
SAS Technical Support
Did you check the other links in the note? I found information relating to your questions. Also the EM Reference Manual has some useful stuff in the Open Source Code Node chapter 72:
http://support.sas.com/documentation/onlinedoc/miner/em132/emref.pdf
Yes, thank you for the docs, but I could not find an answer to my problem.
I have installed the R library in the root as it is recommended in your documentation. Now, the warning message that the library could not be found disappeared. But now, the problem is that the working directory (macro _WORK_DIR) cannot be changed (see picture of the log).
I don't know where is the correct location for installing the library and how to install it. Do you know where and the way to do it ?
Thank you,
Marco
PS: _WORK_DIR is set to "%sysfunc(getoption(work))"
I've haven't installed R yet but we are looking at getting it working soon. I think you should track this problem with SAS Tech Support if you haven't done so already.
Hi mmaccora,
First let me clarify what the R working directory and workspace mean. The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions). At the end of an R session, the user can save an image of the current workspace to a location on the file system, the "working directory", and it will automatically reload the next time R is started. SAS Enterprise Miner's Open Source Integration (OSI) node sets the R working directory to a temporary file, just the same as SAS creates a SAS working directory for each SAS session. These are temporary files that disappear after the session ends. If you turn on options mprint in the project start code and rerun the node, you will see where the OSI node sets the working directory:
NOTE: %INCLUDE (level 1) file _RSUBMIT is file C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2\RSUBMIT.sas.
24560 +_WORK_DIR= "%sysfunc(getoption(work))";
MPRINT(EM_OPEN_TRAIN): _WORK_DIR= "C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2";
We don't recommend changing the work directory, but if you do decide to change it, make sure you have read and write permissions to that location and the location exists.
To answer your original question regarding installation directory and how that works:
In the picture you sent in of the OSI node log, it looks like you are trying to set the working directory for R to tell the OSI node where the libraries are located. You don't need to do this. When you install an R package, the packages install to the location you included in setwd("C:/Program Files/R/R-3.2.5/library"). After they are installed in R, you do not need to point to this location again, even in the OSI node. You simply need to call the library you want to use. The only code you would need to put in the code editor would be:
library(DMwR) &EMR_EXPORT_TRAIN <- SMOTE(form = &EMR_CLASS_TARGET ~ &EMR_CLASS_INPUT + &EMR_NUM_INPUT, data = &EMR_IMPORT_DATA, perc.over = 200, k = 5, perc.under = 1000)
Enterprise Miner passes the code back to R to run, and R already knows where to find these packages. Your code should run successfully without the setwd() command.
I hope this helps!
Jess Mayo
SAS Technical Support
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.