dynamically loads an object file if needed

Usage

load.if.needed(file, fun.name, FUN = dyn.load, ...)

Arguments

file name of an object file. This is the name of a .o file as produced by Fortran or C.
fun.name optionally the name of the function that needs the file. Default is the function calling load.if.needed.
FUN function to actually dynamically load file. By default the function dyn.load() is used.
... any arguments to FUN.

Value

The output of FUN (by default dyn.load) i.e., a character vector of symbols in file (C function names or Fortran subroutine names).

load.if.needed ensures that FUN is invoked only once; it assumes that the object file resides in the parent directory where the calling function is stored; for instance if fast.stats is in /usr/dj/s/.Data and it calls load.if.needed("cmpstats.o") then the file /usr/dj/s/cmpstats.o is dynamically loaded once.

See Also

dyn.load

Examples

fast.stats <- function(x, y, by)
{
	load.if.needed("cmpstats.o")
	out <- .C("by_int",
                x = as.double(x),
                y = as.double(y),
                by = as.integer(by))
	return(out)
}


[Package Contents]