When using knitr with caching, I came across a problem associated with dcast.
It is reported in yihui/knitr #207 and may be the same as
eval(parse(text = "
df = data.frame(x = letters[1:2], y = letters[1:3], z = rnorm(6))
g = c('b', 'a')
dcast(df, y~ordered(x, levels = g))
"), envir = new.env())
Using z as value column: use value.var to override.
Error in factor(x, ..., ordered = TRUE) : object 'g' not found