Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.table factor variable as key throws error in pander.data.table #314

Closed
connorp opened this issue Nov 10, 2017 · 1 comment
Closed

Comments

@connorp
Copy link

connorp commented Nov 10, 2017

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.

@daroczig
Copy link
Member

daroczig commented Jul 8, 2018

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants