How to make a formula for dcast()?