R-beta: autoloading a required library

Albrecht Gebhardt agebhard at zidsrv.sci.uni-klu.ac.at
Mon Nov 17 23:10:21 CET 1997


On Mon, 17 Nov 1997, Thomas Lumley wrote:

> On Mon, 17 Nov 1997, Albrecht Gebhardt wrote:
> 
> > 
> > I wanted to use the dist() function from the mva library in my own
> > library, so I put require(mva) in my files. When my library loads, a
> > message about "Autoloading ... mva" appears. But when I call dist() now
> > within my functions the message
> > 
> > Error in .C("dist", as.double(x), nrow(x), ncol(x), double(len),
> > as.integer(method)) : C/Fortran function not in load table 
> > 
> > appears.
> > 
> > After dyn.load("..._path_to_/mva.so") it works.
> 
> It's probably something wrong with the setup, but I don't know what. It
> seems to work in my installation of R which is roughly 0.50a4.
> 
> Does it work if you use library(mva) instead?  This should be identical
> except that it gives an error if "mva" doesn't exist, rather than a
> warning.
> 
> gorn% R
> 
> R : Copyright 1997, Robert Gentleman and Ross Ihaka
> Version 0.50 Alpha-4 (September 10, 1997)
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type "license()" for details.
> 
> [Previously saved workspace restored]
> 
> > is.loaded("dist")
> [1] FALSE
> > require(mva)
> Autoloading required library: mva 
> [1] TRUE
> > is.loaded("dist")
> [1] TRUE
> > 

This works (but not within the workspace, where my problem occured).

> and even if the require() is inside a function
> > ff<-function(x) require(mva)
> > is.loaded("dist")
> [1] FALSE
> > ff(1)
> Autoloading required library: mva 
> [1] TRUE
> > is.loaded("dist")
> [1] TRUE
> > 

the same behavior.


Now I tried loading my library within a new .RData workspace and
everything worked, but only the first time I use this workspace. 
The second time i get:

R : Copyright 1997, Robert Gentleman and Ross Ihaka
Version 0.50 Alpha-4 (September 10, 1997)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

[Previously saved workspace restored]

> is.loaded("dist")
[1] FALSE
> library(sgeostat)
Autoloading required library: mva 
Autoloading required library: scompat 
> is.loaded("dist")
[1] FALSE
> ls(all=T)
[1] ".Dyn.libs" ".Provided"

.Dyn.libs was created the first time I used this workspace and contains
(immediatly after the second start of R):

> .Dyn.libs
[1] "mva.so"

Maybe this is the reason why "mva.so" did not get loaded. Does R forget to
clear ".Dyn.libs" on shutdown?

Albrecht

------------------------------------------------------------------
Albrecht Gebhardt           email: albrecht.gebhardt at uni-klu.ac.at
Institut fuer Mathematik    Tel. : (++43 463) 2700/837
Universitaet Klagenfurt     Fax  : (++43 463) 2700/834
Villacher Str. 161
A-9020 Klagenfurt, Austria
------------------------------------------------------------------



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=---



More information about the R-help mailing list