Running your R and LaTeX Infrastructure from a portable USB Drive
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
- R 2.14.0 (set up as portable)
- Eclipse 3.7 (set up as portable)
- StatET Plugin for Eclipse (integrates R into Eclipse)
- Rtools 2.14 (set up as portable)
- MikTeX 2.9 Portable (true portable)
- LyX 2.0.2 (set up as portable; make sure you grab the LyX-2.0.x.y-Installer-Bundle.exe as it contains Ghostview and other important stuff)
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 ‘
/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
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.