Portable use of dyn.load to call a C function in an R package -
I am creating an R package which I intend to present in CRN, in which a regular written in C. Calling function. How do I load the CR-routine compiled in a platform-independent manner in the R function? I am able to work my package on my Intel based Mac:
function (myadata) {dyn.load (file.path.library, "mypkg / libs / i386", paste ("Mypkg", .plat $ dynlib.ext, sep = "")) Try (output & lt; - c. ("Myfunc_cversion", in_data = as.double (mydata), res_data = as.double (res), Package = "mypkg")) Results & lt; - as.matrix (output $ res_data) returns (result)}
The problem is the call dyn.load where I can not understand portable ways The complete path to the shared library for your installed package Specify from.
Is there another variable in R. Should I use the library, or better work than dyn.load for this matter?
You will need to see the manual page for where The man page also recommends that you use it only in HTH library.dynam (). For example, you should do this, for example .
function (mydata) {library.dynam ("mysharedobject", package = c ("mypkg")) Try (output & lt; - c. ("Myfunc_cversion", in_data = as .double (mydata), res_data = as.double (res), package = "mypkg")) Results & lt; - as.matrix (output $ res_data) returns (results)}
mysharedobject
is the name of the shared object file endlessly without .dll / .so etc. . .onLoad ()
or . First.lib ()
functions.
Comments
Post a Comment