comify: Function to add commas for large numbers

View source: R/NCmisc.R

comifyR Documentation

Function to add commas for large numbers

Description

Often for nice presentation of genomic locations it is helpful to insert commas every 3 digits when numbers are large. This function makes it simple and allows specification of digits if a decimal number is in use.

Usage

comify(x, digits = 2)

Arguments

x

a vector of numbers, either as character, integer or numeric form

digits

integer, if decimal numbers are in use, how many digits to display, same as input to base::round()

Value

returns a character vector with commas inserted every 3 digits

Examples

comify("23432")
comify(x=c(1,25,306,999,1000,43434,732454,65372345326))
comify(23432.123456)
comify(23432.123456,digits=0)

NCmisc documentation built on Oct. 17, 2022, 5:09 p.m.