title: Apply a function to multiple columns of a SparkDataFrame, at once
body: <p>In basic R, this is how I apply a function to multiple columns at once, using <code>data.table</code> :</p>
  <pre><code>d &lt;- data.table(V1 = rep(1:2, 4:3), V2 = c(1, 2, 4, 5, 2, 3, 4), V3 = 1:7, V4 = sample(letters, 7))
  Cols &lt;- c(&quot;V2&quot;, &quot;V3&quot;)
  d[, (Cols) := lapply(.SD, function(x) x * 100), .SDcols = Cols]
  </code></pre>
  <p>But now,  I'm trying to replicate the same on a SparkDataFrame, in Azure Databricks with <code>SparkR</code>.</p>
  <p>I looked on the side of <code>dapply, ...</code>, of <code>spark.lapply</code>, but I can't figure out how to apply a same function to several columns of a SparkDataFrame.</p>