I would like to call a C function compiled using Matlab Coder in R for later use in a Shiny app. How can I go about doing this. The top of the .C function looks like this:
double ensembleBaggedTreesExtendedStay_V1(double TransferredYesNo,
double BleedDisYesNo,
double PreOpAlbumin, double PreOpHCT,
double ASAClass, double ComplexYesNo)
and the file name for the c function is "ensembleBaggedTreesExtendedStay_V1.c"
I have very limited knowledge of R and .C and I would appreciate any help.
Thanks!
When you'd like to compile MATLAB Coder generated code on your own or pull it into an IDE, you can package your code and all of its compile-time and run-time dependencies using Coder. For example:
That produces
yourFunction.zipcontaining generated sources, dependent headers/sources, and any library dependencies.The documentation link above shows how to do this in the Coder App.
Once you have that ZIP file, you can unzip it and use the command noted in the comments by @tpetzoldt
R CMD SHLIBalong with the extension system to compile all of the C files present in that ZIP file.