glin / reactable

Interactive data tables for R
https://glin.github.io/reactable
Other
613 stars 79 forks source link

Data is not displayed if column name has `[` or `]` #187

Closed statquant closed 2 years ago

statquant commented 2 years ago

Hello, the following breaks for me when trying to render a data.table but not a data.frame:

reactable(data.frame(x=1:3, y=1:3))     

image

reactable(data.frame(x=1:3, `y_[]`=1:3))

image

reactable(data.table(x=1:3, `y_[]`=1:3))

image

Many thanks for the package

glin commented 2 years ago

That's a good catch, thanks for the report. This is now fixed in the development version (https://github.com/glin/reactable/commit/f9b6c81de1fcede08e44b99e7cb6f828c06b1566):

  • Columns with square brackets ([ or ]) in their column name now render correctly (#187).
jonocarroll commented 2 years ago

Just for reference, the same is/was true for a tibble and likely any structure which preserves [ in column names.

data.frame typically converts names with make.names() so this didn't come up so easily with those, but is there any interest in preserving column names through reactable()?