[R] Problem with serialization via readRDS() on a textConnection()
Duncan Murdoch
murdoch.duncan at gmail.com
Wed Aug 9 15:06:35 CEST 2017
On 09/08/2017 9:01 AM, Duncan Murdoch wrote:
> (Sorry for not linking to your message; I accidentally deleted the
> original copy of your message.)
>
> Your code
>
> > zz = textConnection('tempConnection', 'wb')
> > saveRDS(c("a", "b", "c"), zz, ascii = TRUE)
> > serialized_obj = paste(textConnectionValue(zz), collapse='\n')
> > readRDS(textConnection(serialized_obj))
> Error in gzcon(file) : 'read' not enabled for this connection
>
> has one problem: textConnectionValue(zz) may not be the complete text
> because zz hasn't been closed. You should close(zz), then get the
> result from the variable tempConnection.
>
> However, this doesn't fix the problem you saw, which appears to be a bug
> in readRDS or gzcon. I'll post it to the bug list.
Now posted as https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=17325.
Duncan Murdoch
More information about the R-help
mailing list