When we want to call external programs in R under Windows, we often need to know the paths of these programs. For instance, we may want to know where ImageMagick is installed, as we need the convert (convert.exe) utility to convert images to other formats, or where OpenBUGS is installed because we need this path to use the function bugs(). Usually this problem does not exist under Linux, because the executables (or their symbolic links) are often put in the directories which are in the environment variable PATH (e.g. /usr/bin, /usr/local/bin).
However, we may be able to find the paths through the registry if the installation will save the path info in the registry hive. The R function is readRegistry():
There is no guarantee for this approach to work on any Windows platforms, but I think this is better than explaining what is the PATH variable to some Windows users…
Here I show two examples for ImageMagick and OpenBUGS respectively. Make sure you are using Windows and have already installed ImageMagick and OpenBUGS. The first example shows how to find ImageMagick and call it to convert a sequence of images (generated by R) to a GIF animation:
You should be able to see the output as this:
You might now be able to run the above examples in your Windows version, and I’ll appreciate feedbacks from Vista and Win7 users. If the above approaches do not work, you may run the command regedit (Start –> Run) and search for ImageMagick/OpenBUGS, then change my code accordingly, because the locations of the registry hive for ImageMagick/OpenBUGS may not be the same for different versions of Windows. My session info is as below: