r - minimize code for base64 decoding of rds object -


i have r object (saved .rds file) in base64-encoded string:

encoded <- "h4siaaaaaaaabovqywrcmbbc8zi0icicpyhme7yvru0hkezia/xofwvwtuwqc/ewy2syozvjpquabpwxyjwop1dzehyecqkaed5nwnhqa+1ltgccpfgpib1oes5eresd8vvf42+lkr3bmodbzv3xz214ttgxq5bfdscakmbv9y8yenksdpbkukc9q6tmbuevrxkpga+mp2mlcyo+0/6yforlrkst6rkyi36nsinjscx6a7sxoh15aqaa" 

i need load object in r. following question ("base64 encoding .rda file"), came following code:

library("base64enc") conb64 <- file('obj.b64', 'w+b') write(encoded, conb64); close(conb64)  base64decode(file='obj.b64', output = 'obj.rds') myobj <- readrds('obj.rds') 

this works fine minimize code , ideally manage without creating disk files, myobj <- readrds(base64decode(encoded)). there way remove @ least operations?

it seems me there's bug in base64enc package. can reproduced simple executing base64decode(what='anything', output = 'any.name') - gives error:

error in base64decode(what="anything", output = "any.name") :
argument "file" missing, no default

apparently happens because base64decode() use file argument calls file() function. when changed source of function (replaced file filename), worked correctly , code decoded <- base64decode(encoded, = 'raw') gives correct binary rds file. while bug not corrected, 1 can use function of same name catools package: decoded <- base64decode(z = encoded, = 'raw'). however, failed feed readrds() function:

library('catools') decoded <- base64decode(encoded, = 'raw') con1 <- rawconnection(object = dec, open = 'rb') myobj <- readrds(con1) # error in readrds(con1) : unknown input format 


Comments