0

First time question asker.

I created an Excel/R tool that uses:

  • Excel VBA to create a CSV file with data for R,
  • Launch R using a Windows Shell,
  • Detects when R is finished running and then
  • Imports the results in a CSV file created by the R script.

Unfortunately, the R code does not work as programed with some package versions created after 3/1/2020, which creates problems for new users because they cannot just install the current package versions or users who want to use conflicting versions for other projects.

I have a solution for users who do not require newer versions of R for their other work; writing a script that installs all the packages and their dependents using the “versions” package. However, I think this approach will constrain users who want to use newer versions of R. **Is this a correct assumption? **

I thought the {checkpoint} package might offer a good solution. I can get it to run in well in RStudio by creating a RStudio project (where I ran the {checkpoint} package to install the 3/1/2020 versions of my packages). However, I have not found a way to run the R script from the Windows Shell. The R script does not seem to be able to access the packages installed in the RStudio project using {checkpoint}. Does anyone have ideas of how I can have Excel VBA launch the start of the R script in a way that it can assess the packages installed in the RStudio project by {checkpoint}? Perhaps there is a Windows Shell call for RStudio similar to the one I use now for R?

Here is the Windows Shell code I currently use for R in case it helps. It works with the versions approach but not the {checkpoint} approach.

rExeCall = "C:\Program Files\R\R-3.6.2\bin\Rscript.exe"
rExeOptns = " --no-environ --no-init-file --no-restore --verbose  " 
rscrpt=”Tool.R”
Shell (rExeCall & rExeOptns & rscrpt)

Thank you in advance for your help!

I had hoped that my current R shell code would work when I used {checkpoint} to install the correct versions of the packages in an RStudio project.

I tried specifying the .libPaths to the file location for the RStudio projection (per Running R script from PHP in VSCode not recognizing R packages) without success.

shafee
  • 15,566
  • 3
  • 19
  • 47
Swank
  • 1
  • 1
  • I dont know if it would help but there is a package (in development): https://github.com/edugca/xlRcode . Take a look! – Arthur Welle Dec 28 '22 at 02:30
  • Thanks Arthur, this looks interesting. Is there a way to control where you control where xlRcode accesses the proper libraries installed in the RStudio project? – Swank Dec 28 '22 at 15:09

0 Answers0