Skip to content

Instantly share code, notes, and snippets.

View courtiol's full-sized avatar
🇫🇷

Alexandre Courtiol courtiol

🇫🇷
View GitHub Profile

How to use R & Rstudio within containers using podman & rocker (on linux)

In this gist, I will show you how I use the podman container system to run R and RStudio on my laptop running Fedora 42. So I will cover here mainly local usage of podman, but the remote usage is very similar so I will drop a few words about that too. Combining podman and R is relatively straightforward thanks to the rocker project which provides the so-called images one needs. I am using Fedora as my main operating system, so this is the "use case" environment covered here. I expect that what I describe below works for other Linux distros as well; but I did not test it. Also, on Windows and MacOS, there may be some additional steps to get podman running, which I did not look into (I read that one must use a podman machine to create a virtual machine first...). What I show should work with docker instead of

## Brute forcing the 24 puzzle (https://en.wikipedia.org/wiki/24_(puzzle)) and friends
## We create all permutations of maths signs and numbers (e.g. 1 + 1 + 1 + 1, 2 + 1 + 1 + 1, ..., 1 - 1 + 1 + 1, ...)
operators <- c("+", "-", "*", "/")
digits <- as.character(1:9) ## numbers to be used in the game
d_0 <- expand.grid(digit1 = digits, operator1 = operators,
digit2 = digits, operator2 = operators,
digit3 = digits, operator3 = operators,
digit4 = digits, stringsAsFactors = FALSE)