title: Count number of each factor grouping by another factor
body: <p>I know the answer to this question will be simple but I have searched the forums extensively and I have been unable to find a solution. </p>
  
  <p>I have a column called <code>Data_source</code> which is a factor that I want to group my variables by. </p>
  
  <p>I have a series of <code>symptom*</code> variables where I want the counts according to <code>Data_source</code>. </p>
  
  <p>For some reason, I am unable to figure out how to do this. The normal <code>group_by</code> functions do not seem to work appropriately.</p>
  
  <p>Here is the dataframe in question</p>
  
  <pre><code> df &lt;- wrapr::build_frame(
     "Data_source"  , "Sex"   , "symptoms_decLOC", "symptoms_nausea_vomitting" |
       "1"          , "Female", NA_character_    , NA_character_               |
       "1"          , "Female", NA_character_    , NA_character_               |
       "1"          , "Female", "No"             , NA_character_               |
       "1"          , "Female", "Yes"            , "No"                        |
       "1"          , "Female", "Yes"            , "No"                        |
       "1"          , "Female", "Yes"            , "No"                        |
       "1"          , "Male"  , "Yes"            , "No"                        |
       "1"          , "Female", "Yes"            , "No"                        |
       "2"          , "Female", NA_character_    , NA_character_               |
       "2"          , "Male"  , NA_character_    , NA_character_               |
       "2"          , "Male"  , NA_character_    , NA_character_               |
       "2"          , "Female", "Yes"            , "No"                        |
       "2"          , "Female", "Yes"            , "No"                        |
       "2"          , "Male"  , NA_character_    , NA_character_               |
       "2"          , "Male"  , NA_character_    , NA_character_               |
       "2"          , "Male"  , NA_character_    , NA_character_               |
       "2"          , "Female", NA_character_    , NA_character_               |
       "2"          , "Female", NA_character_    , NA_character_               |
       "2"          , "Male"  , NA_character_    , NA_character_               |
       "2"          , "Female", NA_character_    , NA_character_               )
  </code></pre>
  
  <p>Notice that Sex and the symptoms variables are all factors which include NA's. I have attempted the following</p>
  
  <pre><code>df %&gt;% na.omit() %&gt;% group_by(Data_source) %&gt;% count("symptoms_decLOC")
  </code></pre>
  
  <p>Which does not work and is less than optimal because I would have to repeat it for every column. The ideal would be to use something similar to <code>lapply(df, count)</code> but this does not give me description for each group. </p>
  
  <p><em>EDIT</em></p>
  
  <p>In response to question below, I have added the expected output. I have edited this in excel, color coding the <code>group_by</code> for clarity.</p>
  
  <p><a href="https://i.stack.imgur.com/YpxT2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YpxT2.png" alt="enter image description here"></a></p>
  
  <p>Notice how I am getting a break down for each possible answer. When I run this using <code>dplyr</code> here is the output.</p>
  
  <pre><code>&gt; df %&gt;% na.omit() %&gt;% group_by(Data_source) %&gt;% count("symptoms_decLOC")
  # A tibble: 2 x 3
  # Groups:   Data_source [2]
    Data_source `"symptoms_decLOC"`     n
    &lt;chr&gt;       &lt;chr&gt;               &lt;int&gt;
  1 1           symptoms_decLOC         5
  2 2           symptoms_decLOC         2
  </code></pre>