[R-pkg-devel] how to prevent a small package from yielding a large installed size?

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Mon Jun 15 21:12:53 CEST 2020


On 15/06/2020 1:24 p.m., Ivan Krylov wrote:
> On Mon, 15 Jun 2020 12:52:20 -0400
> Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
> 
>> maybe someone else can suggest how to read an object from
>> the .rdb file using R code.  Internally R uses C code for this.
> 
> This function seems to work for me:
> 
> # filename: the .rdb file
> # offset, size: the pair of values from the .rdx
> # type: 'gzip' if $compressed is TRUE, 'bzip2' for 2, 'xz' for 3
> readRDB <- function(filename, offset, size, type = 'gzip') {
> 	f <- file(filename, 'rb')
> 	on.exit(close(f))
> 	seek(f, offset + 4)
> 	unserialize(memDecompress(readBin(f, 'raw', size - 4), type))
> }
> 

Thanks, though it didn't work for me.  I get

Error in unserialize(memDecompress(readBin(f, "raw", size - 4), type)) :
   no restore method available

on every object I tried.  However, maybe Dan will have better luck.

Duncan Murdoch



More information about the R-package-devel mailing list