title: minimize code for base64 decoding of rds object
body: <p>I have R object (saved as .rds file) in base64-encoded string:</p>
  
  <pre><code>encoded &lt;- "H4sIAAAAAAAABoVQywrCMBBc8zi0ICiCPyHme7yVrU0hkEZIA/XofwvWTUwQc/Ewy2SyOzvJpQUABpwxYJwoP1DZEHYECQKaeD5nwnHqa+1LTgCCpfGPIB1Oes5eReSD8VVf42+LKr3bmOdBZV3XZ214tTgXQ5bFdsCAKmBv9Y8yenKsDPbKuKC9Q6tmbUevRxKPGa+MP2mlcYO+0/6YFOrLrksT6RkyI36nSInJsCx6A7sXoh15AQAA"
  </code></pre>
  
  <p>I need to load this object in R. Following this SO question ("<a href="https://stackoverflow.com/questions/24874266/base64-encoding-a-rda-file/">Base64 encoding a .Rda file</a>"), I came to the following code:</p>
  
  <pre><code>library("base64enc")
  conb64 &lt;- file('obj.b64', 'w+b')
  write(encoded, conb64);
  close(conb64)
  
  base64decode(file='obj.b64', output = 'obj.rds')
  myobj &lt;- readRDS('obj.rds')
  </code></pre>
  
  <p>This works fine but I would like to minimize the code and ideally manage without creating disk files, something like <code>myobj &lt;- readRDS(base64decode(encoded))</code>. Is there any way to remove at least some operations?</p>
  
  <p>It seems for me that there's a bug in <code>base64enc</code> package. Can be reproduced by simple executing <code>base64decode(what='anything', output = 'any.name')</code> - gives an error:</p>
  
  <blockquote>
    <p>Error in base64decode(what="anything", output = "any.name") :<br>
    argument "file" is missing, with no default</p>
  </blockquote>
  
  <p>apparently it happens because <code>base64decode()</code> use <code>file</code> as an argument but also calls a <code>file()</code> function. When I changed the source of the function (replaced <code>file</code> to <code>filename</code>), everything worked correctly and code <code>decoded &lt;- base64decode(encoded, what = 'raw')</code> gives correct binary rds file. While the bug is not corrected, one can use the function of the same name from <code>caTools</code> package: <code>decoded &lt;- base64decode(z = encoded, what = 'raw')</code>. However, I failed to feed this to <code>readRDS()</code> function:</p>
  
  <pre><code>library('caTools')
  decoded &lt;- base64decode(encoded, what = 'raw')
  con1 &lt;- rawConnection(object = dec, open = 'rb')
  myobj &lt;- readRDS(con1)
  # Error in readRDS(con1) : unknown input format
  </code></pre>