user10917479
user10917479

Reputation:

Streamline building R Windows Binaries for multiple R versions

I am developing R packages for an internal use applications at work. Unfortunately, not everybody is on the same version of R. I want to build Windows binaries of my package to support multiple versions, for example, 3.6.x and 4.0.x R.

I can easily do this by building the package (I use devtools::build(binary = TRUE)), and then change the R version in RStudio, restart, and run again. But this gets very tedious.

Is there a way to streamline this (e.g., my own custom function to build both at once)? I imagine some CI/CD thing is probably best, but this solution would have to be limited to what I can run locally.

Upvotes: 2

Views: 72

Answers (1)

user2554330
user2554330

Reputation: 44957

Don't do it in RStudio, write a script to do it. It would have commands like these:

/path/to/R3.6.3/R CMD INSTALL --build /path/to/yourpackage
mv yourpackage.*.zip /path/for/R3.6users
/path/to/R4.0.3/R CMD INSTALL --build /path/to/yourpackage
mv yourpackage.*.zip /path/for/R4.0users

You don't need a lot of builds; only the first two parts of the version number (e.g. 3.6 or 4.0) need to match the target system.

You could implement this script in R using system() calls, but it's probably simpler to do it using one of the Windows script languages (.bat or .cmd or whatever).

Upvotes: 3

Related Questions