Dcasting Error in R data frame

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. It really make it easier to help.

I can point to help(dcast) and the example for understanding how the pieces fit

library(reshape2)
# from help(dcast)
names(airquality) <- tolower(names(airquality))
aqm <- melt(airquality, id=c("month", "day"), na.rm=TRUE)
dcast(aqm, month ~ variable, mean, margins = c("month", "variable"))
#>   month    ozone  solar.r      wind     temp    (all)
#> 1     5 23.61538 181.2963 11.622581 65.54839 68.70696
#> 2     6 29.44444 190.1667 10.266667 79.10000 87.38384
#> 3     7 59.11538 216.4839  8.941935 83.90323 93.49748
#> 4     8 59.96154 171.8571  8.793548 83.96774 79.71207
#> 5     9 31.44828 167.4333 10.180000 76.90000 71.82689
#> 6 (all) 42.12931 185.9315  9.957516 77.88235 80.05722

Created on 2020-04-06 by the reprex package (v0.3.0)