Skip to content

Instantly share code, notes, and snippets.

View eveyp's full-sized avatar

Eve Perry eveyp

View GitHub Profile
@eveyp
eveyp / stata_in_R.R
Last active June 6, 2022 03:10
Running Stata inside R
library(reticulate)
use_condaenv("r-reticulate")
sys = import("sys")
orig_executable = sys$executable
sys$executable = py_exe()
pystata = import_from_path("pystata", path = "C:/Program Files/Stata17/utilities")
pystata$config$init('mp')
@eveyp
eveyp / renv_and_singularity.md
Last active September 5, 2022 05:53
renv and Singularity Containers

Using renv in Singularity Containers

The Problem

My HPC runs CentOS while the container is running Ubuntu Focal. This means that when packages link a system dependency, that system dependency might be in different places. So, I can't use the same built binaries for some packages because they'll break when a system dependency they need isn't where it is expected (this happens when a package is built in one OS but loaded in the other).

The Solution

To fix this I need to keep the CentOS and Ubuntu libraries separate from each other. This is simple enough when not using renv, but I'm looking for reproducibility, so I need an renv compatible way to keep the libraries separate.

To do this I define an Renviron.site file that will be used by the container that sets an environmental variables for a prefix for the renvcache and the project library. Then I bind mount the Renviron.site file in the container and renv picks up the environmental variable and keeps things separate.