Modify numbers.

mod_number(x, divideby = 1000, comma_seperator = TRUE, digits = 0)

Arguments

x

A numeric.

divideby

The value you want all of your values divided by. Default = 1000.

comma_seperator

Do you want numbers to have commas in it ("1,000" (T) vs. "1000" (F). Default = TRUE.

digits

How many digits you would like your number to have. Default = 0.

Examples

x = data.frame(matrix(data = c(20000678660, 234567, 1, NA, 2345, 23),
       ncol = 2))
mod_number(x)
#>      [,1]         [,2]
#> [1,] "20,000,679" NA  
#> [2,] "235"        "2" 
#> [3,] "0"          "0" 
mod_number(x,
       comma_seperator = FALSE)
#>      [,1]       [,2]
#> [1,] "20000679" NA  
#> [2,] "235"      "2" 
#> [3,] "0"        "0" 
x = data.frame(matrix(data = c(200000, 234567, 1, NA, 2345, 23)))
mod_number(x,
       divideby = 1,
       digits = 2)
#>      [,1]        
#> [1,] "200,000.00"
#> [2,] "234,567.00"
#> [3,] "1.00"      
#> [4,] NA          
#> [5,] "2,345.00"  
#> [6,] "23.00"