[R] is library loaded

Robert Gentleman rgentlem at fhcrc.org
Tue Sep 13 22:53:16 CEST 2005


Hi,

  Almost surely this is a bad name. With the advent of name spaces it is 
important to distinguish between loading and attaching. This function 
tests for attached packages. To test for loaded packages we already have
  loadedNamespaces.

  Best wishes,
    Robert

John Fox wrote:
> Dear Omar,
> 
> The following function tests whether a package is in the search path (with
> the package name given in quotes):
> 
> packageLoaded <- function(name) 0 != length(grep(paste("^package:", name,
> "$", sep=""), search()))
> 
> I hope this helps,
>  John
> 
> --------------------------------
> John Fox
> Department of Sociology
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox 
> -------------------------------- 
> 
> 
>>-----Original Message-----
>>From: r-help-bounces at stat.math.ethz.ch 
>>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Omar Lakkis
>>Sent: Tuesday, September 13, 2005 2:09 PM
>>To: r-help at stat.math.ethz.ch
>>Subject: [R] is library loaded
>>
>>Is there a way to test if a library has been loaded?
>>
>>is.loaded does not give me what I want, I am looking to say:
>>
>>if loaded(Rdbi) dbSendQuery(conn, q)
>>if loaded(RODBC) sqlQuery(conn, q)
>>
>>I need this to support both unix and windows platforms as I 
>>could not find a windows distribution for RdbiPgSQL. I am 
>>using R 2.1.0 and postgresql. I will be connecting to the 
>>database using Rdbi and RdbiPgSQL and have other developers 
>>using windows connect with RODBC, unless someone can suggest 
>>a better solution.
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! 
>>http://www.R-project.org/posting-guide.html
> 
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
PO Box 19024
Seattle, Washington 98109-1024
206-667-7700
rgentlem at fhcrc.org




More information about the R-help mailing list