r Format numbers with 0 and dashes -
i dealing numbers below
12344 233345 7233433 9343883 3432837 i trying format these number such of same length , dash (-) after every 3 numbers. final expected results should below.
0-012-344 0-233-345 7-233-433 9-343-883 3-432-837 any on formatting these numbers way appreciated.
try formatc:
formatc(x, width = 7, format = "d", flag = "0", big.mark = '-') # [1] "0-012-344" "0-233-345" "7-233-433" "9-343-883" "3-432-837" the data used:
x <- scan(textconnection('12344 233345 7233433 9343883 3432837'))
Comments
Post a Comment