title: Counting non-missing occurrences
body: <p>I need help counting the number of non-missing data points across files and subsetting out only two columns of the larger data frame.</p>
  
  <p>I was able to limit the data to only valid responses, but then I struggled getting it to return only two of the columns.  </p>
  
  <p>I found <a href="http://www.statmethods.net/management/subset.html" rel="nofollow noreferrer">http://www.statmethods.net/management/subset.html</a> and tried their solution, but myvars did not house my column label, it return the vector of data (1:10).  My code was:</p>
  
  <pre><code>myvars &lt;- c("key")
  answer &lt;- data_subset[myvars]
  answer
  </code></pre>
  
  <p>But instead of printing out my data subset with only the "key" column, it returns the following errors:
  "Error in <code>[.data.frame</code>(observations_subset, myvars) : undefined columns selected"  and "Error: object 'answer' not found</p>
  
  <p>Lastly, I'm not sure how I count occurrences.  In Excel, they have a simple "Count" function, and in SPSS you can aggregate based on the count, but I couldn't find a command similarly titled in R.  The incredibly long way that I was going to go about this once I had the data subsetted was adding in a column of nothing but 1's and summing those, but I would imagine there is an easier way.</p>