working R and added codebook