Version 2.1 - replaced 'sapply' with 'dcast'