[Bioc-devel] get rid of require/depends warning

Seth Falcon sfalcon at fhcrc.org
Fri Dec 11 23:04:56 CET 2009

On 12/11/09 6:03 AM, Paolo Sonego wrote:
> Dear Seth,
> Thanks for the useful suggestions. I'm digging the source code of the
> annotate package, it seems really interesting...
> Below a chunk of my code that use require:
> imp.data <- function(...){
> # importing raw.data
> ...
> ...
> ## load the proper annotation package regardless the technology
> if( !grepl("\\.db", raw.data at annotation) ) {
> raw.data at annotation <- paste(raw.data at annotation, ".db", sep="")
> }
> require( raw.data at annotation, character.only=T )
> return(raw.data)
> }

You can avoid the warning by specifying character.only=TRUE.  The check 
actually examines the source code for TRUE so T will not work to avoid 
the warning message.

That said, based on your example, it looks like your actual goal is to 
dynamically load annotation packages.  If that is the case, I would 
recommend using the code that already does this for you in the annotate 
package, and in particular the getAnnMap function might be of use.

One advantage of using the annotate functions is that you should not 
have to worry about the ".db" extension, those functions should figure 
out the right thing.


+ seth

Seth Falcon
Program in Computational Biology | Fred Hutchinson Cancer Research Center

More information about the Bioc-devel mailing list