Displaying 1 result from an estimated 1 matches for "pd_obj".
2005 Aug 17
4
accesing slots of S4 class in C code
...setClass("pd", representation(data="numeric"))
x <- new("pd", data=1:5)
test <- function(pd.obj) {
res <- .C("TestFun", pd.obj)
res}
test(x)
(Of couse I load the DLL as well.)
The corresponding C file has:
SEXP TestFun(SEXP pd_obj)
{
SEXP t=R_NilValue;
PROTECT(t = GET_SLOT(pd_obj, install("data")));
UNPROTECT(1);
return(t);
}
What I hope to get as a result is the (1:5) vector.
In the long term, the vector will be a multi-dimensional array and I
will want to do calculations using its contents in t...