Running your R and LaTeX Infrastructure from a portable USB Drive

December 9, 2011
By

(This article was first published on [R]appster, and kindly contributed to R-bloggers)

On my road to eventually running all of my programs off an USB device I’ve gotten a little bit closer yesterday thanks to input from Duncan Murdoch and Yihui Xie.

Eventually running the entire Windows OS off a USB drive would be nice (not talking about running it as a Virtual Machine, but to have a bootable Windows on USB), so: any hints appreciated ;-)

My current R devel infrastructure consists of

Thanks to everyone providing and maintaing those tools!

When I say ‘set up as portable’, that means I simply took the regular installer, but instead of installing to “C:\Program Files\”, I choose a directory on my USB device. This works (at least for me) surprisingly often. I guess the crucial part is if the respective application requires some MS Windows registry entry or not. If not, then you’re fine with running it in “portable mode”.

Kind of the most important aspect when running portable apps is that you need to turn absolute paths into relative paths for crucial system components.

Regarding Eclipse, R, MikTeX and LyX, this is not a problem in case you are fine with a few initial tweaks.

    • You need to change ‘<LYXDIR>/Ressource/lyxrc.dist’ in order to account for MikTeX’s portable nature. Here’s my last line of that file:
      \path_prefix “$LyXDir\bin;$LyXDir\python;$LyXDir\imagemagick;$LyXDir\ghostscript;$LyXDir\..\..\MiKTeX\2.9\miktex\bin”
    • You need to/should write some wrapper functions that give you the relative paths to portable R’s library and destdir folder (which you probably want to be on your USB device as well; per default R installs packages to your harddrive, thus they are “lost” if you switch computers)

Yet, I’ve struggled with Rtools quite a while because I didn’t know how to alter the Windows System PATH based on some script, preferably an R script. Duncan Murdoch sent me some information about the MS Windows registry key that needs to be altered and AFAIU that’s how it’s done when you run the Rools Installer on Windows and opt that you’re fine with the installer altering your path. However, I didn’t feel up to the task of tweaking the registry. In case anyone is interested, this is what Duncan told me:

“We use the Inno Setup installer; it has a function for this.  Here’s the code used:

Root: HKLM; Subkey: SYSTEM\CurrentControlSet\Control\Session Manager\Environment; ValueType: expandsz; ValueName: PATH; ValueData: “{code:getNewPath}”; Tasks: setPath “

Now, yesterday while checking out the new knitr package from Yihui (very nice work by the way! And while where at it: props to Tal Galili for providing www.r-bloggers.com; great source of info, go check it out!), I came across his little R script add-R-path-win.R that does exactly what I was looking for. I adapted it a little to fit my needs. You can find it at my GitHub repo:

https://github.com/Songpants/RappsterMisc/blob/master/R/pathWindowsUpdate.R


To leave a comment for the author, please follow the link and comment on his blog: [R]appster.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.