Set significant figures...

Hi there, is there a way to set the significant figures displayed in the shiny website without impacting the underlying calculations? (i.e., I don't want the round the actual values, I just want to be able to set a single setting that changes all displayed values).

Thanks for any help.

Only affects character representation, not numeric value

formatC(pi,1)
#> [1] " 3"
formatC(pi,2)
#> [1] "3.1"
formatC(pi,3)
#> [1] "3.14"
formatC(pi,4)
#> [1] "3.142"
formatC(pi,5)
#> [1] "3.1416"

Created on 2023-05-02 with reprex v2.0.2

Ah ok, thanks! Is there anything similar that can be applied to the whole Shiny page, rather than each calculation individually?

I’ve been away from Shiny for a while, but I don’t recall anything.

If you use knitr::kable, gt or DT::datatable to display tables of data, each of them has their own way of formatting numbers for entire columns, including significant figures. If you use textOutput, you need to format numbers yourself in each instance. I'm not aware of a global solution.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.