Hi Arsalan,
Proceed with the steps outlined below to call the C function generated by MATLAB coder in R using .C( ) –
- Modify your “ensembleBaggedTreesExtendedStay_V1” function such that it returns void and stores the desired result in one or more arguments expressly created for this purpose. Also, the function should have a C_ prefix.
- Compile the function into a shared library accessible to R using this command:
R CMD SHLIB ensembleBaggedTreesExtendedStay_V1.c
- Within an active R session, link to the shared library using dyn.load("ensembleBaggedTreesExtendedStay_V1.so").
- Write an R wrapper to call the C function using .C with the following syntax: .C("C_my_func", arg1, arg2).
Hope this resolves your query. Happy coding !