title: Calculate row mean, ignoring NAs in Spark Scala
body: <p>I'm trying to find a way to calculate the mean of <strong>rows</strong> in a Spark Dataframe in Scala where I want to ignore NAs. In R, there is a very convenient function called rowMeans where one can specify to ignore NAs:</p>
  
  <pre><code>rowmeans(df,na.rm=TRUE)
  </code></pre>
  
  <p>I'm unable to find a corresponding function for Spark Dataframes, and I wonder if anyone has a suggestion or input if this would be possible. Replacing them with 0 won't due since this will affect the denominator.</p>
  
  <p>I found a similar question <a href="https://stackoverflow.com/questions/36360540/spark-sum-of-row-values">here</a>, however my dataframe will have hundreds of columns. </p>
  
  <p>Any help and shared insights is appreciated, cheers!</p>