Skip to content

add something like nice_dollar #83

@gka

Description

@gka

I was writing this hack recently

t_dollar <- dollar_format(suffix = 'T')
b_dollar <- dollar_format(suffix = 'b')
m_dollar <- dollar_format(suffix = 'm')
k_dollar <- dollar_format(suffix = 'k')

nice_dollar <- function(x) {
    sapply(x, FUN=function(amount) {
        if (is.na(amount)) return('n.a.')
        if (amount > 9e11) return(t_dollar(amount/1e12))
        if (amount > 9e8) return(b_dollar(amount/1e9))
        if (amount > 9e5) return(m_dollar(amount/1e6))
        if (amount > 9e2) return(k_dollar(amount/1e3))
        dollar(amount)
    })
}

which is useful in scenarios with free scales

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementwipwork in progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions