title: How to load .rds R file as a Spark dataframe in Scala
body: <p>I am trying to create a production data pipeline for a model . As a part of this pipeline, I save a model which runs in <code>R</code> environment as <code>.rds</code> file. Here is an example - </p>
  
  <pre><code>set.seed(345)
  
  df = data.frame(x = rnorm(20))
  
  df = transform(df , y = 5 + (2.3*x) + rnorm(20))
  
  ## model
  m1 = lm(y ~ x , data = df)
  
  ## Take out the coefficients 
  coeff = m1$coefficients
  
  &gt; coeff
  (Intercept)           x 
     4.938554    2.328345
  
  ## save the model coefficients
  saveRDS(coeff, "~/Desktop/coeff.rds")
  </code></pre>
  
  <p>Now, I would like to somehow load these <code>coefficients</code> in a Scala program as a <code>Spark Dataframe</code>, which might look something like this - </p>
  
  <pre><code>val loadCoefficients = # some method to load .rds file as a Spark Data frame
  </code></pre>
  
  <p>Is there any library that can allow me to achieve this? My end result in Spark context should look like - </p>
  
  <pre><code>loadCoefficients.show
  org.apache.spark.sql.DataFrame
  (Intercept)           x 
     4.938554    2.328345
  </code></pre>