[R] pass an element in a list() from R to C

teazrq rzhu at live.unc.edu
Thu Oct 13 04:52:04 CEST 2011


so, I did this:

B= list("a" = 1, "b" = 2, "c" = 3)

.C("myfunction", B)


the c code is :

SEXP myfunction(SEXP matrix_temp)
{
    Rprintf("this element is %6.3f", REAL(VECTOR_ELT(matrix_temp,1))[0]);
}

but after runing the R code, it says Error: VECTOR_ELT() can only be applied
to a 'list', not a 'NULL'
I guess this is because I did not acturally pass a list to the c function,
but why is that?

--
View this message in context: http://r.789695.n4.nabble.com/pass-an-element-in-a-list-from-R-to-C-tp3900221p3900426.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list