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.urba...@r-project.org> wrote: > Saptarshi, > > how did you create those lists? Can you send us the code? If not, can you > put up the .RData file? Without a reproducible example this is hard to debug > ... > > Thanks, > Simon > > > On Oct 1, 2009, at 14:26 , Saptarshi Guha wrote: > >> Hello, >> I have list of 600K lists, each sublist a list of two elements, the first >> a character, the second a list of six named elements, some characters some >> numrics. >> LISTA (600K) (:= h) >> |__ List of two elements >> |__ Character >> |__ Named List of 6 elements (characters and numerics) >> >> This works, >> sip <- lapply(h,function(r) r[[2]][['sip']]) >> >> but I wish to unlist this >> >> sip <- unlist(lapply(h,function(r) r[[2]][['sip']])) >> >> and get the following error: >> Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'list' >> Debugging to find which: >> >> i<-1 >> sip <- unlist(lapply(h,function(r) { >> i<<-i+1 #debug messages >> cat(i,"------------------>","\n"); print( r[[2]] ) #debug message >> r[[2]][['sip']] >> })) >> >> [1]Error in print.default(r[[2]]) : 'getEncChar' must be called on a >> CHARSXP >> >> >> Which occurs on the 122,204'th item. All entries r[[2]] are similar so I >> don't know why this happening? >> The strangest thing is that this error never happened a few days ago and >> the same code causes this to occur today. >> >> >> Any ideas would be helpful. >> Regards >> Saptarshi >> >> ______________________________________________ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> > > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel