# Mathematica Rlink [closed]

I am trying to run a series of computations using RLink. First I initialize the tools I need:

Needs["RLink"];
InstallR[];
REvaluate["install.packages('fitdistrplus' repos='http://cran.wustl.edu/')"];
REvaluate["install.packages('actuar',repos='http://cran.wustl.edu/')"];
REvaluate["library(fitdistrplus)"]; REvaluate["library(actuar)"];


Then it is the code:

BootDistPareto[data_, n_] := Module[{},
RSet["data", data];
RSet["n", n];
REvaluate["{
st <- c('shape'=10,'scale'= 10)
memp <- function(x, order) ifelse(order==1, mean(x), sum
(x^order)/length(x))
fit <- fitdist(data, 'pareto',order=c(1,2),
method='mme',  memp='memp' ,start=st,lower=1, upper=Inf)
fit <- bootdist(fit,'nonparam',niter=n)
sfit <- summary(fit)
sfit
}"]]


I want to run the function for a dataset like this:

BootDistPareto[{7, 5, 7, 98, 7, 5, 3, 1, 5}, 10]


When I run the same code in R I easily get the answer. But what I get in Mathematica is:

The following R error was encountered: Error in function (data, distr,
order, memp, start = NULL, fix.arg = NULL,  :
'start' must specify names which are arguments to 'distr'


I think the problem is RLink is not able to transfer my code when I specify start=c(shape=10,scale= 10) .

Does any body know what is the right way of implementing these few lines of code?

-
Is the 'c' function defined somewhere, or is it a standard function? –  Sjoerd C. de Vries May 7 at 11:01
Please provide complete self-contained example, including Mathematica sample data you are trying to feed into your function, as well as all your RLink session (perhaps, you load some R libraries etc) - otherwise it is hard to tell what's wrong. –  Leonid Shifrin May 7 at 11:30
@SjoerdC.deVries c is a standard constructor for arrays in R, but the functions fitdist and bootdist` seem specialized. –  Leonid Shifrin May 7 at 11:33
@MortezaShahrezaye Thanks for simplifying it! Have you tried doing the same in R directly? It seems it gives the same error, so the problem is not with RLink/Mathematica, but the R code itself. I'm not familiar with fitdist/bootdist though, so I don't know what is going wrong. –  Szabolcs May 7 at 13:12
Since the problem was on the R side (not RLink/Mathematica), and you already found a solution, I'm voting to close this as too localized. –  Szabolcs May 7 at 14:55
show 5 more comments

## closed as too localized by Szabolcs, Leonid Shifrin, whuber, rcollyer, Sjoerd C. de VriesMay 7 at 17:10

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.