{"Error: could not find function \"InterVA\"\n"}

Nov 22, 2016 at 4:26 PM
Dear All,

I want to run the Function InterVA in C# using R.net, but the running gives me this error: {"Error: could not find function \"InterVA\"\n"}. I have checked in internet using Google even in this web site but nothing.

The used code is below

public REngine _engine;
public ActionResult GetInterVADataInCSVFormat()
        string strDelimiter = ",";
        string cs = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
        StringBuilder sb = new StringBuilder();
        //DataTable VA_Data = new DataTable();
        using (SqlConnection con = new SqlConnection(cs))
            SqlDataAdapter da = new SqlDataAdapter("SELECT ID, elder, midage, adult, child, under5, infant, neonate, male, female, magegp1, magegp2, magegp3, died_d1, died_d23, died_d36, died_w1, acute, chronic, sudden, wet_seas, dry_seas, heart_dis, tuber, hiv_aids" 
                + ",hypert, diabetes, asthma, epilepsy, cancer, copd, dement, depress, stroke, sickle, kidney_dis, liver_dis, measles, men_con, mencon3, malaria, malarneg, fever, ac_fever, ch_fever, night_sw, cough, ac_cough, ch_cough"
                + ",pr_cough, bl_cough, whoop, breath, rapid_br, ac_rpbr, ch_rpbr, br_less, ac_brl, ch_brl, exert_br, lying_br, chest_in, wheeze, ch_pain, yellow, diarr, ac_diarr, pe_diarr, ch_diarr, bl_diarr, vomiting, bl_vomit, abdom"
                + ",abd_pain, ac_abdp, ch_abdp, swe_abd, ac_swab, ch_swab, abd_mass, ac_abdm, ch_abdm, headache, skin, skin_les, sk_feet, rash, ac_rash, ch_rash, measrash, herpes, stiff_neck, ac_stnk, ch_stnk, coma, co_ons, convul"
                + ",ac_conv, ch_conv, unc_con, urine, uri_ret, exc_urine, uri_haem, wt_loss, wasting, or_cand, rigidity, swell, swe_oral, swe_neck, swe_armp, swe_breast, swe_gen, swe_oth, swe_legs, anaemia, exc_drink, hair, paral_one"
                + ",eye_sunk, bl_orif, vb_bet, vb_men, vb_after, diff_sw, not_preg, pregnant, del_6wks, pend_6w, first_p, more4, cs_prev, multip, lab_24, died_lab, death_24, baby_al, breast_fd, del_fac, del_home, del_else, prof_ass"
                + ",del_norm, del_ass, del_cs, baby_pos, mon_early, hyster, bpr_preg, fit_preg, vis_bl, bleed, e_bleed, s_bleed, d_bleed, p_bleed, placent_r, disch_sm, term_att, abort, born_early, born_3437, born_38, ab_size, born_small"
                + ",born_big, twin, comdel, cord, waters, move_lb, cyanosis, baby_br, born_nobr, cried, no_life, mushy, fed_d1, st_suck, ab_posit, conv_d1, conv_d2, arch_b, font_hi, font_lo, unw_d1, unw_d2, cold, umbinf, b_yellow, devel"
                + ",born_malf, mlf_bk, mlf_lh, mlf_sh, mttv, b_norm, b_assist, b_caes, b_first, b_more4, b_mbpr, b_msmds, b_mcon, b_mbvi, b_mvbl, b_bfac, b_bhome, b_bway, b_bprof, injury, traffic, o_trans, fall, drown, fire, assault, venom"
                + ",force, poison, inflict, suicide, alcohol, smoking, married, vaccin, treat, t_ort, t_iv, blood_tr, t_ngt, antib_i, surgery, sur_1m, disch, shospf, strans, sadmit, streat, smedic, smore2, sdoubt, stradm, smobph, scosts"
                + "  FROM [dbo].[VINTERVA_DATA]", con);
            DataSet ds = new DataSet();
            DataTable VA_Data = ds.Tables[0];
            ds.Tables[0].TableName = "InterVA";

            IEnumerable<string> columnNames = ds.Tables["InterVA"].Columns.Cast<DataColumn>().Select(column => column.ColumnName);
            sb.AppendLine(string.Join(",", columnNames));

            foreach (DataRow row in ds.Tables["InterVA"].Rows)
                IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());
                sb.AppendLine(string.Join(",", fields));

            string path = Server.MapPath(@"~/DataSet/InterVAInput.csv");

            FileInfo file = new FileInfo(path);
            if (file.Exists)

            using (StreamWriter InterVAInput = new StreamWriter(path, true))

            DataManager myData = new DataManager(); 

            // Initialization of R engine
            _engine = REngine.GetInstance();

            using (_engine)
                    //string dataFileName1 = path.Replace(@"\\", @"/");
                    var dataFilePath = path.Replace("\\", "/");
                    string dataFile = dataFilePath;
                    string dir = Server.MapPath("~/DataSet/");
                    var dataDir = dir.Replace("\\", "/");
                    //Create R PATH for csv data file
                    _engine.Evaluate(string.Format("FilePath <-'{0}'", dataFile));

                    _engine.Evaluate(string.Format("dirPath <-'{0}'", dataDir));

                    // Read CSV data in R
                    _engine.Evaluate("VAINPUT<-read.table(FilePath, header=TRUE, sep = ',')");

                    // retrieve the data frame
                    DataFrame ds1 = _engine.Evaluate("VAINPUT").AsDataFrame();

                   _engine.Evaluate("InterVA(VAINPUT, HIV = 'l', Malaria = 'l', directory = dirPath, filename = 'VA_result3', output = 'classic', append = FALSE, groupcode = FALSE, replicate = FALSE)");

                   DataFrame df= _engine.Evaluate("InterVA(VAINPUT, HIV = 'h', Malaria = 'l',directory = dirPath, filename = 'VA_result',output = 'extended', append = FALSE, replicate = TRUE, groupcode = FALSE)").AsDataFrame();



Thank you very much for your assistance