Hi Everyone,
I am new to R and I am trying to return array(dynamic) from C to R. But
when I print array(vector) in R it gives NA as output. When I print array
in C it gives correct o/p but some how it is not returned to R.

*Code in C:*
void test(double *vec,double *size){
vec = (double *)calloc(2 , sizeof(double));
        *(vec+0) = 1;
        *(vec+1) = 2;
        *size = 2;
}

*Code in R:*
test<-.C("test",vec=as.double(),size=as.integer())
print(test$vec[1:test$size])

Is there any other way to implement above thing?

Any help would be appreciated
Thanks

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to