I would like to use a list in C, that i got from R. I realise the question is very similar to this: Passing a data frame from-to R and C using .call(). However, I fail in storing it in a pointer "*target", from where i would further use it.
R:
.Call("processlist", list(c(1,2), c(1,3,2), c(1,5,4,4)))
and in C:
#include <Rinternals.h>
#include <Rdefines.h>
extern "C" {
SEXP processlist(SEXP lst);
}
SEXP processlist(SEXP lst){
SEXP vec = PROTECT(allocVector(VECSXP, 2));
SET_VECTOR_ELT(vec, 0, VECTOR_ELT(c, 0);
SET_VECTOR_ELT(vec, 1, VECTOR_ELT(c, 1);
SET_VECTOR_ELT(vec, 2, VECTOR_ELT(c, 2);
const lngth = 3;
int *target[lnght];
// Here i want to fill "target", but how?
int *preTarget = INTEGER(vec);
// Bad attempts
target[0] = INTEGER(preTarget[0]);
target[0] = INTEGER(vec[0]);
}
Note: C++ is not an Option unfortunately.
Edit: Desired output would be that I can call *target the following way.
target[0][0] --> Returns: 1
target[1][2] --> Returns: 2
target[2][3] --> Returns: 4
Calling "vec" in that way throws me an error at the moment.