title: lapply() showed two different results when using with leveneTest()
body: <p>I have this dataframe list containing different dataframes.</p>
  <pre class="lang-r prettyprint-override"><code>df_list &lt;- list(
    `1.3.A` = 
      tibble::tribble(
        ~Person, ~Height, ~Weight,
        &quot;Alex&quot;,    175L,     75L,
        &quot;Gerard&quot;,    180L,     85L,
        &quot;Clyde&quot;,    179L,     79L,
        &quot;Alex&quot;,    175L,     75L,
        &quot;Gerard&quot;,    180L,     85L,
        &quot;Clyde&quot;,    179L,     79L
  
      ),
    `2.2.A` = 
      tibble::tribble(
        ~Person, ~Height, ~Weight,
        &quot;Alex&quot;,    175L,     75L,
        &quot;Gerard&quot;,    180L,     85L,
        &quot;Clyde&quot;,    179L,     79L,
         &quot;Alex&quot;,    175L,     75L,
        &quot;Gerard&quot;,    180L,     85L,
        &quot;Clyde&quot;,    179L,     79L
      ), 
    `1.1.B` = 
      tibble::tribble(
        ~Person, ~Height, ~Weight,
        &quot;Alex&quot;,    175L,     75L,
        &quot;Gerard&quot;,    180L,     85L,
        &quot;Clyde&quot;,    179L,     79L,
        &quot;Alex&quot;,    175L,     75L,
        &quot;Gerard&quot;,    180L,     85L,
        &quot;Clyde&quot;,    179L,     79L
      )
  )
  </code></pre>
  <p>What I was trying to do was to test for homogeneity of variance among groups (Person in this case). But after several trials of piping lapply() with leveneTest() my codes showed two different results.</p>
  <p>This particular code worked and gave me the result I was looking for.</p>
  <pre class="lang-r prettyprint-override"><code>ht &lt;- function(df){ 
    leveneTest(df$Height ~ df$Person)
  }
  
  final_ht &lt;- lapply(df_list, ht)
  </code></pre>
  <p>However, for this code</p>
  <pre class="lang-r prettyprint-override"><code>wood &lt;- lapply(df_list, function(i) ~leveneTest(y = Height, group = Person, data = i))
  </code></pre>
  <p>would give a result showing <code>&lt;environment: 0x55869b4289b8&gt;</code></p>
  <p>I have no idea why the function in <code>wood</code> didn't return or run the leveneTest.
  What is happening  with <code>lapply()</code> in both codes?
  Can somebody enlighten me on what <code>lapply()</code> is doing on both cases?</p>
  <p>Also, in the code <code>ht</code> it  returns a  warning, is this ok?</p>
  <pre class="lang-r prettyprint-override"><code>In leveneTest.default(y = y, group = group, ...) : 
  group coerced to factor. Error in cat(&quot;1: In leveneTest.default(y = y, 
  group = group, ...) : group coerced to factor.&quot;,  : 
    argument 2 (type 'list') cannot be handled by 'cat'
  </code></pre>
  <p>Would very much appreciate any help.</p>