glin / reactable

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

The special sentinel `.rownames` doesn't work as expected #378

Closed olivroy closed 2 months ago

olivroy commented 3 months ago
data.frame(.rownames = c(1, 1, 0), vs = c(1, 2, 3)) |> reactable::reactable(rownames = T)

I get this table currently on R 4.3.2 image

However in ?reactable::reactable, it is documented that if you set a column name to .rownames, it will be used as row name.

I would expect only the vs column to show up with 1, 1, 0 as row names

Oops, I think I misunderstood. I thought that if I named a column .rownames, it would overwrite row names

glin commented 3 months ago

Ahh yeah, I see how the doc can be interpreted that way. There should be some clarification that .rownames is what you put in the list of column definitions in reactable(..., columns = list(...)).

There is an example of customizing the row names column here in the docs though, https://glin.github.io/reactable/articles/examples.html#row-names

If you want to get the original example working, you'd have to set row.names on the data frame instead:

data.frame(row.names = c(1, 2, 0), vs = c(1, 2, 3)) |> reactable::reactable()
glin commented 2 months ago

Updated the docs in https://github.com/glin/reactable/commit/363068caab2fa708b247a4ab0f73cdc694223587