<div dir="ltr">Hi All,<div style> I am using RInside and trying to call the R code below.</div><div style><br></div><div style><p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)">std::string rcode = "CausalEffectCDP = function(obs.data, init_effect){ \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span>ITERATIONS=10; \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span>causal_effect = init_effect; \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> formula_str = \"\"; \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> column_names = names(obs.data); \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"> num_columns = length(column_names); \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"> if(num_columns < 4){ \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> formula_str = \"outcome ~ treat\";\</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> }else{\</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> outcome = column_names[num_columns]; \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"> treat = column_names[2]; \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> cdp_vertex = column_names[3]; \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"> }\</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"><span class="" style="white-space:pre"> </span> return (formula_str); \</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(59,63,251)"> }"<span style="color:rgb(0,0,0)">;</span></p></div><div style><br></div><div style>To execute it and get the result I use :</div><div style>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span style="color:rgb(10,48,200)"> R</span>-><span style="color:rgb(120,64,145)"><b>parseEvalQ</b></span>(rcode);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>Rcpp::<span style="color:rgb(0,96,66)">Language</span> cdpCall(<span style="color:rgb(59,63,251)">"CausalEffectCDP"</span>,obs_data, init_effect);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>std::<span style="color:rgb(0,96,66)">string</span> temp=Rcpp::as<std::<span style="color:rgb(0,96,66)">string</span>>(cdpCall.<span style="color:rgb(120,64,145)"><b>eval</b></span>());</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span class="" style="white-space:pre"> </span></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span style="font-family:arial;font-size:small">However, I am getting the following error : </span><br>
</p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">"Error evaluating:" CausalEffectCDP <- ...<span style="font-family:arial;font-size:small"><br></span></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">
<br></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span style="font-family:arial;font-size:small">The number of columns in the dataframe is 3 and when I remove the "if statement" the error </span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span style="font-family:arial;font-size:small">goes away. Any help is greatly appreciated.</span><br></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px">
<span style="font-family:arial;font-size:small"><br></span></p><p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><span style="font-family:arial;font-size:small">George</span></p></div></div>