June 19 – 23, 2023

I’m condensing this week into one post for two reasons: I have been battling with R-Python integration into my WSL server ALL WEEK, and someone broke into my car. I’ve been working on getting both things sorted, but the code stuff is likely more interesting to you.

So, for all you uninitiated out there: CRAN is NOT ubuntu native. That means that in order to use CRAN packages and R in ubuntu, you need to download everything from a translated CRAN version made by Michael Rutter. And while it feels as though it should be simple and intuitive – it is not. You’re going to have to bypass your Ubuntu security features through the ubuntu .config file using an inline text editor so that each file can be downloaded intact. Once you’ve cleared that hurdle, you need to make sure your R packages are being downloaded to the right place, and once you do that you’ll probably realize that your R version doesn’t match the requirements for the packages. You’ll then need to download the versions of R you need, which should be as easy as

sudo apt-get install r-base = 4.2* 

or some such, but you would be incorrect. The R versions in ubuntu are definitely not cleanly labelled, so in order to find the version label you need, you gotta deep dive into the internet to find them in order to find this command in the annals of the “ask ubuntu” logs:

apt policy r-base

which will allow you to look at a list of the ubuntu versions of R and then input the correct one into the first command.

If you then need to download packages from GitHub like I did, you’ll need the devtools package. Which cannot be downloaded through R without special Ubuntu libraries. Searching for them is a nightmare. Using this solution worked for me. Hopefully it works for you. In all honesty, this was the first time things in Linux/WSL where downloading things ran into more roadblocks than when I use Windows .

Once all that nonsense is installed, its a simple matter of finding the right R path for your Python packages to use. Which, I realized, is apparently a huge ask because WSL runs on a server. So that means that your pathing will look like this: \\wsl.localhost\Ubuntu-22.04\usr\bin\Rscript or some such wierdness. <—- Python/os pathing hates this. With a vigorous passion. I’m hoping and praying that I can figure out how to just add my R directly to my PATH so that the “default” option of these things fills in the blanks for me. That is a task for another day though, and in this case, another week.

By:

Posted in:


Leave a comment

Design a site like this with WordPress.com
Get started