title: Test-driven Data Analysis?
body: <p>Several R packages have been developed that allow you to make assertions about your data, results of analysis, etc. However, I have never seen anyone compile a list of useful checks. </p>
  
  <p>Are there any resources that have checklists or other lists of common checks?</p>
  
  <p>For example, if you were analyzing survey data, you might want to sanity check the data as follows:</p>
  
  <ul>
  <li>Impossible values: Someone who lists a profession of doctor is 6 years old</li>
  <li>Unlikely correlations: Education level has a negative correlation with Earnings</li>
  </ul>
  
  <p>After doing a lot of joins, you want to verify the final data structure:</p>
  
  <ul>
  <li>Lost observations: A data set begins with N = 100,000... after appending variables, does N still equal 100,000?</li>
  <li>Unreasonable values within columns: Summaries of nulls, detection of outliers, distribution of most common values</li>
  <li>Unreasonable cross-column relationships: A table with sales references salesperson, but the salesperson ID doesn't exist in the salesperson table</li>
  </ul>
  
  <p>After developing predictions, you want to check if they make sense:</p>
  
  <ul>
  <li>Unlikely predictions across groups: You average predicted probabilities of making a purchase by group and find that non-pet owners are more likely than pet owners to buy pet food</li>
  </ul>
  
  <p>etc. etc.</p>
  
  <p>Below are some <strong>R</strong> packages that would help incorporate such tests into <strong>R</strong>... if only we had a checklist of what those tests should be!</p>
  
  <hr>
  
  <p><strong>testthat</strong></p>
  
  <p><a href="http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Wickham.pdf" rel="nofollow">http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Wickham.pdf</a>
  <a href="https://github.com/hadley/testthat" rel="nofollow">https://github.com/hadley/testthat</a></p>
  
  <p><strong>RUnit</strong></p>
  
  <p><a href="http://cran.r-project.org/web/packages/RUnit/vignettes/RUnit.pdf" rel="nofollow">http://cran.r-project.org/web/packages/RUnit/vignettes/RUnit.pdf</a></p>
  
  <p><strong>Svunit</strong></p>
  
  <p><a href="http://cran.r-project.org/web/packages/svUnit/vignettes/svUnit.pdf" rel="nofollow">http://cran.r-project.org/web/packages/svUnit/vignettes/svUnit.pdf</a></p>