Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload R package with compiled extensions

Tags:

package

r

Is it possible to reload an R package with native extensions in an R session? I am developing Rliblinear, which uses several C functions. If I make a change to R code in the package, I can just reinstall and reload;

$ R CMD build Rliblinear
$ R CMD INSTALL Rliblinear

and then in an R shell;

> detach("package:Rliblinear", unload=TRUE)
> library(Rliblinear)

However, the C functions are not affected unless I restart the R interpreter. Is there a way I can force the interpreter to reload the shared object, Rliblinear.so?

like image 746
Kevin L. Avatar asked Mar 21 '11 17:03

Kevin L.


1 Answers

This will list your loaded dynamic link libraries:

library.dynam()

and this will unload Rliblinear.* in the Rliblinear package.

library(Rliblinear)

# ... run package ...

detach("package:Rliblinear", unload = TRUE)
library.dynam.unload("Rliblinear", system.file(package = "Rliblinear"))

You can issue library.dynam() again just to check that its no longer listed.

like image 52
G. Grothendieck Avatar answered Sep 23 '22 04:09

G. Grothendieck