'Display trailing zeros with signif

I am creating tables displaying numerical data with the gt package in R. I need to display 2 significant figures in my table and want to show trailing zeros if relevant (for aesthetic purposes). For example, I need the number 0.301 to display as 0.30. The number 0.000502 to display as 0.00050. How do I do this? The function signif() displays these values as 0.3 and 0.0005.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source