I need to optimize some functions that are in the C language, but using genetic algorithms packages in R.
Is there any way to call C functions in R?
In matlab I know that there is this possibility through "mex". Is there something similar in R?
Yes, there is a way to call C functions in R. Have a look at .C() and .Call() and .External() and most of all at the Writing R Extensions manual.
Related
I consider switching from R, Python and SAS to Julia and wondering whether Julia has convenient tools for out-of-core operations. I intend to use Julia on datasets of the size 10-20 Gb, so I would like to be able to manipulate them without loading them into RAM. Is there any package in Julia, allowing Julia to ‘just work’ with larger-than-RAM data the way SAS functions work?
JuliaDB is a dataframe package in Julia which allows for out-of-core computations, online (streaming) statistics, and parallelism.
I have defined some R functions in R studio which has some complicated scripts and a lot of readlines. I can run them successfully in R studio. Is there any way, like macros to transfer these user-defined functions to SAS 9.4 to use? I am not pretty familiar with SAS programming so it is better just copy the R functions into SAS and use it directly. I am trying to figure out how to do the transformation. Thank you!
You can't natively run R code in SAS, and you probably wouldn't want to. R and SAS are entirely different concepts, SAS being closer to a database language while R is a matrix language. Efficient R approaches are terrible in SAS, and vice versa. (Try a simple loop in R and you'll find SAS is orders of magnitude faster; but try matrix algebra in R instead).
You can call R in SAS, though. You need to be in PROC IML, SAS's matrix language (which may be a separate license from your SAS); once there, you use submit / R to submit the code to R. You need the RLANG system option to be set, and you may need some additional details set up on your SAS box to make sure it can see your R installation, and you need R 3.0+. You also need to be running SAS 9.22 or newer.
If you don't have R available through IML, you can use x or call system, if those are enabled and you have access to R through the command line. Alternately, you can run R by hand separately from SAS. Either way you would use a CSV or similar file format to transfer data back and forth.
Finally, I recommend seeing if there's a better approach in SAS for the same problem you solved in R. There usually is, and it's often quite fast.
Is there a way to call a Mathematica function from R? I'm using RStudio.
I'm trying to build a 'package' in Mathematica and call it from R. By the way, for this to work, would the person need to have mathematica installed?
I've seen packages written in C++, being called in R. The system didn't seem to have any c++ compiler/editor installed...
Any help would be appreciated.
I am working on clustering of variables in matlab. Two functions come in ClustOfVar package in R, called hcluster() and cutreevar().
I am good in Matlab and would like to use alternatives of hcluster() and cutreevar() in it.
Does Matlab has any inbuilt function which computes exactly same as hcluster() and cutreevar() does in R?
Need help.
Thanks
for heirarchical clustering you'll probably want to look at clusterdata. Note that you'll need the statistical toolbox for this function.
What is the equivalent of MATLAB's quadprog function in R in terms of function specification?
Note that it is not the R package quadprog (although the optimization procedure is the identical).
The R library quadprog uses the 'meq' argument to distinguish between equality and inequality constraints whereas MATLAB has separate arguments for these two. The MATLAB approach is far more convenient for my purposes.
It's not a big deal to transform my arguments to fit but it would be a nice convenience if there is an implementation in R that matches the specification in MATLAB.
Note:
MATLAB quadprog documentation
R quadprog documentation
If you can make the translation and you just want a more convenient function you'll have to make your own wrapper. There is no more similar solution in a package. Someone on here might do it for you but it sounds like you can do it yourself.