title: R Language: How do I print / see summary statistics for sample subset?
body: <p>These are some newbie questions about statistical programming for R for which I haven't been able to find an answer online.  <em>My dataframe is labeled "eitc" in the code below.</em></p>
  
  <p><strong>1)</strong> Once I've loaded in a data frame, I would like to look at summary statistics.  I've used the functions:</p>
  
  <pre><code>eitc &lt;- read.dta(file="/Users/Documents/eitc.dta")
  summary(eitc)
  sapply(eitc,mean,na.rm=TRUE) #for sample mean, min, max, etc.
  </code></pre>
  
  <p>How do I find summary statistics on my dataframe when certain qualifications are met.  For example, I would like to see the summary statistics on all variables when the variable "children" is greater than or equal to 1.  The equivalent Stata code is:</p>
  
  <pre><code>summarize if children &gt;= 1
  </code></pre>
  
  <p><strong>2)</strong> Similarly, how do I find specific parameters when certain qualifications are met?  For example, I want to find the mean of the variable "work" when both "post93" variable is equal to zero and "anykids" variable is equal to 1.  The equivalent Stata code is:</p>
  
  <pre><code>mean work if post93==0 &amp; anykids==1
  </code></pre>
  
  <p><strong>3)</strong> Ideally, when I run the summary statistics above, I would like to find out how many observations were included in the calculation / fit the criteria.</p>
  
  <p><strong>4)</strong> When I read in my data frame, it would also be nice to see how many observations are included in the data set (and perhaps how many rows have missing values or "NA" in them).</p>
  
  <p><strong>5)</strong> Also, I have been creating dummy variables using the following code.  Is this the correct way to do it or is there a more efficient route?</p>
  
  <pre><code>post93.dummy &lt;- as.numeric(eitc$year&gt;1993)
  eitc=cbind(eitc,post93.dummy)
  </code></pre>