Skip to content
Prev 34268 / 63421 Next

Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character' & 'getEncChar' must be called on a CHARSXP

Hello
I could send a .Rdata file but it doesn't load throwing a similar error.
I can go through the code (below)

Now if instead of A0-A3 and B0-B3, i simply create a RAWSEXP and copy the the
raw bytes (in kvhold) return this list of two-element lists containing raw bytes
and then call
lapply(h, function(r) list(rhuz(r[[1]],r[[2]]))) #where h is what is
returned from the code below
where rhuz is a wrapper around the functions called in A0-A3, it works

So i'm quite confused here.
Thank you for your time
(R-2.9.1)
Regards
Saptarshi
//using NewList and GrowList from R sources
SEXP rv;
PROTECT( rv = NewList());
while(true){
// read an integer kvlength
// then read kvlength bytes into kvhold
// (from a file)

  // The KEY
  PROTECT(l = Rf_allocVector(VECSXP,2));
  REXP *rexp1 = new REXP(); //A0
  rexp1->ParseFromArray( kvhold, kvlength ); //A1
  PROTECT(k = message2rexp(*rexp1)); //A2
  delete(rexp1); //A3
  SET_VECTOR_ELT( l, 0, k);


// read an integer kvlength
// then read kvlength bytes into kvhold
// (from a file)

  // The VALUE
  REXP *rexp2 = new REXP(); //B0
  rexp2->ParseFromArray( kvhold, kvlength );//B1
  PROTECT(k = message2rexp(*rexp2));//B2
  delete(rexp2); //B3
  SET_VECTOR_ELT( l, 1, k);
	
  //Rf_PrintValue successfully prints both k for all k
  UNPROTECT(3); // the two k's and l
  rv = GrowList(rv, l);
  //We break when kvlength==-1
 }

//now return a list containing the objects
//similar to code in R src/main
rv = CDR(rv);
SEXP rval;
PROTECT(rval = Rf_allocVector(VECSXP, Rf_length(rv)));
for (int n = 0 ; n < LENGTH(rval) ; n++, rv = CDR(rv)){
  SET_VECTOR_ELT(rval, n, CAR(rv));
 }
UNPROTECT(2); //rval and rv
return(rval)

On Thu, Oct 1, 2009 at 5:36 PM, Simon Urbanek
<simon.urbanek at r-project.org> wrote: