title: R: serialize objects push to text file then to hive and back again
body: <p>With Reference to following to questions already asked on stack overflow</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/2258511/r-serialize-objects-to-text-file-and-back-again">R: serialize objects to text file and back again</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/3955108/serializing-rdata-file-to-database">Serializing .RData file to database</a></p></li>
  </ul>
  
  <p>I am trying to achieve the following: 
  Suppose there are data for 2 country</p>
  
  <pre><code>d1 &lt;- data.frame(x=rnorm(100),y=rnorm(100))
  d2 &lt;- data.frame(x=rnorm(100),y=rnorm(100))
  m1 &lt;- lm(x~y,data=d1);m2 &lt;- lm(x~y,data=d2)
  m1.ser &lt;- rawToChar(serialize(m1,NULL,ascii=TRUE))
  m2.ser &lt;- rawToChar(serialize(m2,NULL,ascii=TRUE))
  res &lt;- data.frame(country=c('c1','c2'),model=c(m1.ser,m2.ser))
  </code></pre>
  
  <p>After this I want to use <code>write.table</code> to write out the file in text and then push the file to hive. So while writing out to the file because of \n line alignments get disturbed and hence pushing it to hive becomes problematic.</p>
  
  <p>I am also aware of the fact that I can use <a href="http://cran.r-project.org/web/packages/digest/index.html" rel="nofollow noreferrer" title="digest">digest</a> package to serialize</p>
  
  <pre><code>m1.ser1 &lt;- digest(m1,ascii=TRUE)
  m2.ser1 &lt;- digest(m2,ascii=TRUE)
  </code></pre>
  
  <p>But I am not sure how to get the original models m1,m2 back from them. May be I am missing out something very simple.</p>
  
  <p>Any help, pointers will be very much appreciated. </p>
  
  <p>On a different note are this serializations cross-platform? I understand PMML is built exactly for this purpose. But is it possible for other languages like python, java be able to figure out at least the coeffecients and model properties from the R serialization?</p>
  
  <p>Thanks,</p>