Søren Højsgaard
2008-Jul-12 20:23 UTC
[R] How to build a package which loads Rgraphviz (if installed)...
Dear List, I use Rgraphviz for display of graphs in some packages. Since Rgraphviz is no longer on CRAN it needs to be installed from Bioconductor and that is fine, but I have trouble figureing out the following: I create a plot method which - if Rgraphviz is installed - uses Rgraphviz for displaying and otherwise does nothing. This is implemented as: if (!("package:Rgraphviz" %in% search())){ if("Rgraphviz" %in% installed.packages()){ require(Rgraphviz) } else { cat("The Rgraphviz package (from Bioconductor) must be installed to display the models\n") return() } } ... else go on and do the plotting... When I run rcmd check packagename (on Windows XP, using R.2.7.1) I get * checking for unstated dependencies in R code ... WARNING 'library' or 'require' calls not declared from: Rgraphviz See the information on DESCRIPTION files in the chapter 'Creating R packages' of the 'Writing R Extensions' manual. I can not state Rgraphviz in the Depends-field of the DESCRIPTION file because then the package does not pass the windows checks for going on CRAN. I can not see any solution from "writing R extensions", but I apologize if I have overlooked it. Does anyone have a suggestion on what to do? Cheers S?ren
William Revelle
2008-Jul-12 21:47 UTC
[R] How to build a package which loads Rgraphviz (if installed)...
Soren, When I had an almost identical problem last year. I also wanted to use Rraphviz but only if people had it. Kurt Hornik suggested that I replace a direct call to the function, foo, that uses Rgraphviz with if(require("Rgraphviz")) foo() Bill At 10:23 PM +0200 7/12/08, S?ren H?jsgaard wrote:>Dear List, >I use Rgraphviz for display of graphs in some >packages. Since Rgraphviz is no longer on CRAN >it needs to be installed from Bioconductor and >that is fine, but I have trouble figureing out >the following: I create a plot method which - if >Rgraphviz is installed - uses Rgraphviz for >displaying and otherwise does nothing. This is >implemented as: > > > if (!("package:Rgraphviz" %in% search())){ > if("Rgraphviz" %in% installed.packages()){ > require(Rgraphviz) > } else { > cat("The Rgraphviz package (from >Bioconductor) must be installed to display the >models\n") > return() > } > } > ... else go on and do the plotting... > >When I run rcmd check packagename (on Windows XP, using R.2.7.1) I get > >* checking for unstated dependencies in R code ... WARNING >'library' or 'require' calls not declared from: > Rgraphviz >See the information on DESCRIPTION files in the chapter 'Creating R >packages' of the 'Writing R Extensions' manual. > >I can not state Rgraphviz in the Depends-field >of the DESCRIPTION file because then the package >does not pass the windows checks for going on >CRAN. I can not see any solution from "writing R >extensions", but I apologize if I have >overlooked it. Does anyone have a suggestion on >what to do? > >Cheers >S?ren > > > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Attend ISSID/ARP:2009 http://issid.org/issid.2009/