reactable icon indicating copy to clipboard operation
reactable copied to clipboard

Format column of double to scientific notation

Open jliu215 opened this issue 3 years ago • 1 comments

Awesome package! I have a question.

Is it possible to format a column of double to scientific notation in reachable parameters? I am looking for something like this:

reachable(data, columns = list(
    dbl_column = colDef(format = colFormat(scientific = TRUE, digit = 3)
   )
) 

The reason that I am not using format(scientific = TRUE) before passing it to reactable is because format(scientific = TRUE) converts my numbers to strings which I think fails reactable's build-in sort functionality.

thank you.

jliu215 avatar Jul 21 '22 00:07 jliu215

Hi, scientific notation isn't supported by the built-in column formatters, but I think it's common enough that it'd make sense as a feature request.

For now, you can use a custom render function to implement your own custom formatter. If you do the formatting with a custom render function instead of modifying the data passed into reactable(), cells will appear formatted, but still be sorted on the original underlying data.

glin avatar Aug 06 '22 23:08 glin