[Rcpp-devel] calling Rf_initEmbeddedR error

Romain Francois romain at r-enthusiasts.com
Wed Sep 8 12:03:03 CEST 2010


Hi,

This looks like a question for R-devel mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Regards,

Romain

Le 08/09/10 11:56, Young-Ju Park a écrit :
> Hi all,
>
> I have a problem of Rf_initEmbeddedR function.
> I've tried with:
>   try
>   {
>    int Argc1 = 1;
>    char *Argv1[] = {"Rtest_1"};
>    int Argc2 = 1;
>    char *Argv2[] = {"Rtest_2"};
>    // Init R(first)
>    Rf_initEmbeddedR(Argc1, Argv1);
>    // R package load
>    SEXP e = R_NilValue;
>    SEXP r = R_NilValue;
>    PROTECT(e = lang2(install("source"), mkString("hreg.r")));
>    r = R_tryEval(e, R_GlobalEnv, NULL);     // -----> success
>    UNPROTECT(1);
>    // Function load
>    SEXP fun;
>    PROTECT(e = allocVector(LANGSXP, 3));
>    fun = findFun(install("hreg"), R_GlobalEnv);
>    if(fun == R_NilValue)                   // -----> success
>    {
>     UNPROTECT(1);
>     throw std::range_error("R Function not found");
>    }
>    SETCAR(e, fun);
>    UNPROTECT(1);
>    // End R
>    R_dot_Last();
>    Rf_endEmbeddedR(0);
>     R_gc();
>    /////////////////////////////
>    // Init R(second)
>    Rf_initEmbeddedR(Argc2, Argv2);
>    // R package load
>    e = R_NilValue;
>    r = R_NilValue;
>    PROTECT(e = lang2(install("source"), mkString("hbnreg.R")));
>    r = R_tryEval(e, R_GlobalEnv, NULL);    // -----> NULL return
>    UNPROTECT(1);
>    // Function load
>    PROTECT(e = allocVector(LANGSXP, 3));
>    fun = findFun(install("hbnreg"), R_GlobalEnv);   // -----> Exception
> Error
>    if(fun == R_NilValue)
>    {
>     UNPROTECT(1);
>     throw std::range_error("R Function not found");
>    }
>    SETCAR(e, fun);
>    UNPROTECT(1);
>    // End R
>    R_dot_Last();
>    Rf_endEmbeddedR(0);
>     R_gc();
>   }
>   catch(std::exception& ex)
>   {
>    m_strErrMsg = ex.what();
>    return S_FALSE;
>   }
>   catch(...)
>   {
>    m_strErrMsg = "Exception: unknown reason";
>    return S_FALSE;
>   }
> -----------------------------
> my work environment :
> R version : 2.11.1
> Development Language : VC++
> OS : WinXP Pro sp3
>
> Thanks and best regards.
>
> Young-Ju, Park
> from Korea

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




More information about the Rcpp-devel mailing list