rdplyrformattable

Format number to currency in dplyr?


I am looking to format Quote dollars number to a currency format within dplyr verbs with no cents included. Rounded up to the nearest dollar. Here is the code I have so far and its output. How can I get quote dollars to go from a number (1000.5 to $1001)?

$ ADD_PROD_DESC          <chr> NA, NA, "Copper White 147-1472G", "Copper White 147-1472G", "Copper White 147-1472G", "Copper White 147-1472G", "Copper White 147-1472G", "Copper White~
$ Manufacturer_Model_NBR <chr> NA, "1404N42-00", "147-1472G", "147-1472G", "147-1472G", "147-1472G", "147-1472G", "147-1472G", "147-1472G", "147-1672G", "147-1672G", "147-1672G", "14~
$ Call_For_Price         <chr> "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "FALSE", "TRUE", "TRUE~
$ Quote_Dollars          <dbl> 1784781.3, 1008000.0, 746010.0, 703822.5, 703822.5, 703822.5, 703822.5, 646818.5, 646818.5, 613302.3, 560757.6, 560757.6, 560757.6, 560757.6, 519990.0,~

Solution

  • You can use the package scales:

    Quote_Dollars <- scales::dollar_format()(data$Quote_Dollars)
    

    dollar_format round to the closest by default.