title: Count number of observations without N/A per year in R
body: <p>I have a dataset and I want to summarize the number of observations without the missing values (denoted by NA). </p>
  
  <p>My data is similar as the following:</p>
  
  <pre><code>data &lt;- read.table(header = TRUE, 
                 stringsAsFactors = FALSE, 
                 text="CompanyNumber ResponseVariable Year ExplanatoryVariable1 ExplanatoryVariable2
                 1 2.5 2000 1 2
                 1 4 2001 3 1
                 1 3 2002 NA 7
                 2 1 2000 3 NA
                 2 2.4 2001 0 4
                 2 6 2002 2 9
                 3 10 2000 NA 3")
  </code></pre>
  
  <p>I was planning to use the package dplyr, but that does only take the years into account and not the different variables:</p>
  
  <pre><code>library(dplyr)
  data %&gt;% 
    group_by(Year) %&gt;%
    summarise(number = n())
  </code></pre>
  
  <p>How can I obtain the following outcome?</p>
  
  <pre><code>                    2000 2001 2002
  ExplanatoryVariable1  2   2    1 
  ExplanatoryVariable2  2   2    2
  </code></pre>