Replace cast() by dcast() from reshape2
Replace X1/X2 by Var1/Var2

reshape2's melt() names its columns Var1/Var2
while reshape used to name them X1/X2