Le 24/09/10 13:31, Alessandro Torrisi a écrit :
Thanks :-)

Just for full information this is the content of my object:

         vector<double> nav;
         vector< vector<double> > cashFlows;
         string creationDate;
         string activationDate;
         string finalDate;
         string benchmark;
         vector<string> dates;
         vector<string> datesBmk;
         vector< vector<double> > indexesBmk;
         vector< vector<double> > weightsBmk;
         double start;
         string type;

Are those objects automatically wrapped by Rcpp ?

yep.

note that vector< vector<double> > is converted into a list of numeric vectors.

My environment is Linux Ubuntu 32 bit with R version 2.11.1 (2010-05-31).
Do you need more info ?

What versions of Rcpp and RInside are you using ?

It would be useful if you can provide a small reproducible example so that we can debug it on our end.

Thanks in advance,
Alex

On Fri, Sep 24, 2010 at 1:18 PM, Romain Francois
<[email protected] <mailto:[email protected]>> wrote:

    Le 24/09/10 13:07, Alessandro Torrisi a écrit :

        Hi!

        I'm new to the group, to rcpp and to C++ also :-P


    welcome.


        I'm trying to embed R in a little program which loads a txt
        file, parses
        it into an object and calls a function developed by our R coders.

        What I aim to do is to move one of our actual Java procedures
        (built on
        Java/Rserve architecture) to C++/RInside/Rcpp, I think we could
        have lot
        of improvements in this way.

        This is a snippet of the procedure:

             R["nav_in"] = Rcpp::wrap(input.nav);
             R["cashFlows_in"] = Rcpp::wrap(input.cashFlows);
             R["dates_in"] = Rcpp::wrap(input.dates);
             R["indexesBmk_in"] = Rcpp::wrap(input.indexesBmk);
             R["weightsBmk_in"] = Rcpp::wrap(input.weightsBmk);
             R["benchmark_in"] = Rcpp::wrap(input.benchmark);
             R["datesBmk_in"] = Rcpp::wrap(input.datesBmk);
             R["creationDate_in"] = Rcpp::wrap(input.creationDate);
             R["activationDate_in"] = Rcpp::wrap(input.activationDate);
             R["finalDate_in"] = Rcpp::wrap(input.finalDate);
             R["start_in"] = Rcpp::wrap(input.start);
             R["type_in"] = Rcpp::wrap(input.type);


    I think the Rcpp::wrap is redundant, you could e.g. write :

    R["nav_in"] = input.nav ;


             SEXP res;

             string evalstr = "res <- portfolioBenchmark(nav_in,
        cashFlows_in,
        dates_in, indexesBmk_in, weightsBmk_in, benchmark_in, datesBmk_in,
        creationDate_in, activationDate_in, finalDate_in, start_in,
        type_in); res";
             res = R.parseEval(evalstr);

        What I obtain is the following:

        Errore in .Call("R_isMethodsDispatchOn", onOff, PACKAGE = "base");
            Numero di argomenti errato (2), ce ne vogliono 1 per
        R_isMethodsDispatchOn
        terminate called after throwing an instance of
        'Rcpp::binding_not_found'
        what(): binding not found: '.AutoloadEnv'
        Aborted

        Excuse for the message, which is an Italian/English mix...
        What is this error about ?


    Which platform are you using ?

    There seem to be an initialization problem, which I think I have
    only seen on windows so far, hence my question.


    And then... the result of the

        "portfolioBenchmark" function should be a list..How can I
        convert the
        returned SEXP res into a list ?


    You could do this I suppose:

    Rcpp::List mylist( res ) ;


        Thanks in advance,
        Alessandro Torrisi.

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/cCmbgg : Rcpp 0.8.6
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
`- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th


_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to