Hello,

Consider this little function (not concerned about efficiency here)

m=function(r) { a<-serialize(r,NULL); zz<-rawConnection(raw(0),"r+");
writeBin(length(a),zz); c(rawConnectionValue(zz),a)}
a=m(10)

p=rawConnection(a,"r+"); u=readBin(p,"int")
unserialize(p)


Error in unserialize(p) : unknown input format

But isn't p a connectio?From ?unserialize

'unserialize' reads an object (as written by 'serialize') from
     'connection' or a raw vector.

Also, seek(p,where=NA) returns 0 when it should return 5.

I could do unserialize( a[ 5:(5+u)] ) but sticking with the connection
would be nicer.


Cheers
Saptarshi

______________________________________________
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