Using Renviron in command line automated tasks

I'm currently using the community desktop edition, and I'd like to automate some scripts that can take advantage of the .Renviron file. However, I have been unable to do this. I can automate an R script, but it doesn't seem to pull the .Renviron info. Do I need the server edition to do this?

The script is executed by R not by RStudio (it is just an IDE for the R programming language) so it wouldn't make any difference.

.Renviron files are defined at your user home folder or at project level so you have to make sure that the Script is executed on those folders or you can set the environmental variables at R-version level with a Renviron.site file.

Then I'm at a loss. I put it in the folder with the R script, I've put it in the user folder, in the user/documents folder, and in the folder R runs (just suggestions I found while searching) and none were successful. Maybe I'll look into creating a Renviron.site file. Thanks!

It would be easier to help you if you could put together a minimal reproducible example of your issue so we can try ourselves and give you more specific advice.

That would have been kind of difficult as a script runs manually with .Renviron, and runs without it when automated under the same user. So I was chasing folders and environment variables all over the place.

However, I stumbled over my own denseness as I found that the file being ran was using Rscript.exe. When I changed it to R CMD BATCH it worked like a charm. I appreciate your desire to help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.