title: Evaluate multiline codeblock with microbenchmark
body: <p>Is it possible to evaluate a codeblock consisting of multiple lines of code with microbenchmark? If so, how?</p>
  
  <p>Example:
  We have some numeric data in character columns:</p>
  
  <pre><code>testdata &lt;- tibble::tibble(col1 = runif(1000), col2 = as.character(runif(1000)), col3 = as.character(runif(1000)))
  </code></pre>
  
  <p>Now we can try different ways of converting these.
  We can directly call as.numeric on the columns:</p>
  
  <pre><code>testdata$col2 &lt;- as.numeric(testdata$col2)
  testdata$col3 &lt;- as.numeric(testdata$col3)
  </code></pre>
  
  <p>We could try doing it inside a <code>dplyr</code> mutate:</p>
  
  <pre><code>testdata &lt;- dplyr::mutate(testdata, col2 = as.numeric(col2),
                 col3 = as.numeric(col3))
  </code></pre>
  
  <p>Or maybe we know all columns should be numeric so we can try something less explicit that does some checking:</p>
  
  <pre><code>testdata &lt;- dplyr::mutate_if(testdata, .predicate = is.character, .funs = as.numeric)
  </code></pre>
  
  <p>Now we want to compare the performance of these 3 options.</p>
  
  <p>The latter 2 options are individual calls so these can easily be tested in microbenchmark, but the first option consists of two separate calls. We could wrap the two calls in a function and then evaluate that in microbenchmark, but this introduces the slight overhead of the function, so isn't technically evaluating the solution that we have now. We can include the calls separately in the microbenchmark and then add them up after, for the mean should do fine, but for things like the min or the max this doesn't necessarily give sensible results.</p>
  
  <p>The examples in the docs for microbenchmark mostly use simple individual expressions and often use a simple function to wrap code. </p>
  
  <p>Is it possible to directly input multiple lines of code into microbenchmark to be evaluated together?</p>