Search code examples
rshinycurrencydashboard

How to format currency values in valueBox shinydashboard?


I'm trying to write a dashboard with shinydashboard in R to display some values using renderValueBox and valueBoxOutput. These values are not hardcoded but are being scraped from another source daily. These values are currency numbers and should be reporting like $XXX,XXX.XX but instead I see XXXXXX.XX. Is there a way, like a wrapper, to easily format those values? Otherwise I've thought of brute forcing some regex on it with gsub...but ew. Please and thanks :)


Solution

  • Discovered the function prettyNum(): this function is amazing for simple conversion to comma separated numerics.

    > prettyNum(56789, big.mark = ",")
    > 56,789