[Rcpp-devel] Question

George Baah georgebaah at gmail.com
Sun Jan 20 22:12:31 CET 2013


Hi All,
  I am using RInside and trying to call the R code below.

std::string rcode = "CausalEffectCDP = function(obs.data, init_effect){ \

ITERATIONS=10; \

causal_effect = init_effect; \

    formula_str = \"\"; \

    column_names = names(obs.data); \

            num_columns = length(column_names); \

            if(num_columns < 4){ \

   formula_str = \"outcome ~ treat\";\

    }else{\

       outcome = column_names[num_columns]; \

               treat = column_names[2]; \

           cdp_vertex = column_names[3]; \

            }\

    return (formula_str); \

         }";

To execute it and get the result I use :

        R->*parseEvalQ*(rcode);

Rcpp::Language cdpCall("CausalEffectCDP",obs_data, init_effect);

std::string temp=Rcpp::as<std::string>(cdpCall.*eval*());

However, I am getting the following error  :

"Error evaluating:" CausalEffectCDP <- ...


The number of columns in the dataframe is 3 and when I remove the "if
statement" the error

goes away. Any help is greatly appreciated.


George
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130120/6c4be279/attachment.html>


More information about the Rcpp-devel mailing list