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 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)}  

where mysharedobject is the name of the shared object file endlessly without .dll / .so etc. .

The man page also recommends that you use it only in .onLoad () or . First.lib () functions.

HTH



Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -