wrote codebook.md; fixed avgdata()