title: How to create, structure, maintain and update data codebooks in R?
body: <p>In the interest of replication I like to keep a codebook with meta data for each data frame. A data codebook is:</p>
  
  <blockquote>
    <p>a written or computerized list that provides a clear and comprehensive description of the variables that will be included in the database.  <em>Marczyk et al</em> (<a href="http://books.google.com/books?id=IhLlSGyJwcwC&amp;pg=PT225&amp;lpg=PT225&amp;dq=r+data+codebook&amp;source=bl&amp;ots=_QZsMQdva6&amp;sig=d0oYZ8GqG0dd2fia0Au3GuDQD_E&amp;hl=en&amp;ei=s0eBTbfdHOux0QGLqbmDCQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=7&amp;ved=0CDsQ6AEwBg#v=onepage&amp;q&amp;f=false" rel="nofollow noreferrer">2010</a>)</p>
  </blockquote>
  
  <p>I like to document the following attributes of a variable:</p>
  
  <blockquote>
    <ul>
    <li>name</li>
    <li>description (label, format, scale, etc)</li>
    <li>source (e.g. World bank)</li>
    <li>source media (url and date accessed, CD and ISBN, or whatever)</li>
    <li>file name of the source data on disk (helps when merging codebooks)</li>
    <li>notes</li>
    </ul>
  </blockquote>
  
  <p>For example, this is what I am implementing to document the variables in data frame <em>mydata1</em> with 8 variables:</p>
  
  <pre><code>code.book.mydata1 &lt;- data.frame(variable.name=c(names(mydata1)),
       label=c("Label 1",
                "State name",
                "Personal identifier",
                "Income per capita, thousand of US$, constant year 2000 prices",
                "Unique id",
                "Calendar year",
                "blah",
                "bah"),
        source=rep("unknown",length(mydata1)),
        source_media=rep("unknown",length(mydata1)),
        filename = rep("unknown",length(mydata1)),
        notes = rep("unknown",length(mydata1))
  )
  </code></pre>
  
  <p>I write a different codebook for each data set I read.  When I merge data frames I will also merge the relevant aspects of their associated codebook, to document the final database.  I do this by essentially copy pasting the code above and changing the arguments. </p>