The problem is that the end of each row in the table is a \\
which has an optional argument to specify how much space to leave before the next row, for example, \\[1in]
. There's allowed to be white space between the \\
and the [
, so in this case, it's trying to read the [2,5)
as that argument.
A simple workaround would be to change the labels of the factor to include some non-printing blank character first, however, if you do so, by default, print.xtable
will "sanitize" it so that it actually does print, so you'd need to turn that off by passing a new sanitize function; identity
will do none of this fixing.
levels(x.freq$Var1) <- paste0("{}", levels(x.freq$Var1))
print(xtable(x.freq),include.rownames=FALSE, sanitize.text=identity)