When using pander to print a data.table, if the first variable on which the table is keyed is a factor variable, pander causes an error to be thrown. The problem is on lines 258 and 260 of S3.R:
row.names.dt <- x[[data.table::key(x)[1]]]
If the first variable is a factor variable, then when you attempt to set the row.names:
data.table::setattr(x, 'row.names', row.names.dt)
An error is thrown:
Error in setattr(test, "row.names", test[[key(test)[1]]]) :
row names must be 'character' or 'integer', not 'integer'
Coercing row.names.dt to character before passing it to setattr() should solve the issue.
When using pander to print a data.table, if the first variable on which the table is keyed is a factor variable, pander causes an error to be thrown. The problem is on lines 258 and 260 of
S3.R
:If the first variable is a factor variable, then when you attempt to set the
row.names
:An error is thrown:
Coercing
row.names.dt
to character before passing it tosetattr()
should solve the issue.