loading packages conditionally

Posted on
Picture of user. mspiegel Joined: 07/31/2009

The OpenMx repository has a work-in-progress feature that generates graphs from RAM style models. This package requires the Rgraphviz library. I don't want to add Rgraphviz as a required library. Not all users will need to make graphs, and it turns out that the Rgraphviz library can be a pain to install on Windows (you need a specific version of the Graphviz library that is hidden on their website). So this feature conditionally works if the Rgraphviz package is installed. I've added some runtime tests to zzz.R that conditionally create S4 classes that are subclasses of classes defined in the Rgraphviz package. The odd thing is that R 2.9.1 on Windows does some kind of static analysis and believes the Rgraphviz package is required. So I see a message "loading Rgraphviz" package when the OpenMx library is loaded, even when Rgraphviz is not installed. Odd behavior from R, just wanted to appraise the developers of the matter.

Replied on Sat, 08/22/2009 - 22:46
Picture of user. mspiegel Joined: Jul 31, 2009

Umm, nevermind. It looks like I'll just translate our models to DOT directly. Feel free to take a look at section 2.1 of "How To Plot A Graph Using Rgraphviz" and then figure out how to plot reciprocated edges when the source and sink are identical, which seems to involve some wacky combination of S3 methods spanning across the Rgraphviz and graph packages, and a call to a C function Rgraphviz_buildEdgeList where the underlying behavior is hardwired for their purposes.