[R] Writing to gzcon with rawConnection

Jamie Olson jamie.f.olson at gmail.com
Fri May 2 20:50:27 CEST 2014


I would like to encode/decode some text with deflate/gzip, but I'm
having trouble.

Decoding values from a rawConnection is fairly straightforward, but
I'm having trouble encoding values and then retrieving them.

> gz_out <- gzcon(raw_out <- rawConnection(raw(0),open="wb"))
> writeLines("test",con=gz_out)
> flush(gz_out)
> rawConnectionValue(raw_out)
Error: cannot allocate vector of size 131069.2 Gb
> raw_out <- rawConnection(raw(0),open="wb")
> writeLines("test",con=raw_out)
> rawConnectionValue(raw_out)
[1] 74 65 73 74 0a


Has anyone had success doing this?

--Jamie



More information about the R-help mailing list