title: Is it possible to count by using the count function within across()?
body: <p>Hello R and tidyverse wizards,</p>
  <p>I try to count the rows of the starwars data set to know how many observations we get with the variables &quot;height&quot; and &quot;mass&quot;
  .
  I managed to get it with this code:</p>
  <pre><code>library(tidyverse)
  
  starwars %&gt;%
    select(height, mass) %&gt;%
    drop_na() %&gt;%
    summarise(across(.cols = c(height, mass),
                     list(obs = ~ n(),
                          mean = mean,
                          sd = sd))) %&gt;%
    View() 
  </code></pre>
  <p>I would like to replace the <code>obs = ~ n()</code> by the <code>count</code> function and tried this version:</p>
  <pre><code>library(tidyverse)
  
  starwars %&gt;%
    select(height, mass) %&gt;%
    drop_na() %&gt;%
    summarise(across(.cols = c(height, mass),
                     list(obs = count,
                          mean = mean,
                          sd = sd))) %&gt;%
    View() 
  </code></pre>
  <p>but it was too simple to work, classic :p</p>
  <p>I had this error message --&gt; Error in View : Problem while computing <code>..1 = across(...)</code></p>
  <p>And when I got rid of the View() function, I had another error message --&gt; Error in <code>summarise()</code>:
  ! Problem while computing <code>..1 = across(...)</code>.
  Caused by error in <code>across()</code>:
  ! Problem while computing column <code>height_obs</code>.
  Caused by error in <code>UseMethod()</code>:
  ! no applicable method for 'count' applied to an object of class &quot;c('integer', 'numeric')&quot;</p>
  <p>So, I got two questions:</p>
  <ul>
  <li><p>could someone please explain why the code worked with <code>~ n()</code> but not with <code>count</code>?</p>
  </li>
  <li><p>is it possible to use the <code>count</code> function instead of <code>~ n()</code> in that case?</p>
  </li>
  </ul>
  <p>Sorry if it is a dumb question but I just try to understand the <code>across</code> and the <code>count</code> functions by playing with it.</p>