I am trying to display a tibble with formatted numbers in order to ease the reading of the table by using a usual format style for that data type.
Optimally I am searching for something in the line of the scales package for ggplot2 such that the following would be possible:
t <- tibble(
surface = c(98000, 178000000000, 254000000),
price = c(517244, 939484, 1340612),
rate = c(0.12, 0.07, 0.045)
)
print(t,
label = c(
surface = label_number_si(),
price = label_dollar(),
rate = label_percent()
)
)
# A tibble: 3 x 3
surface price rate
<dbl> <dbl> <dbl>
1 98k $ 517 244 12.0%
2 178B $ 939 484 7.0%
3 254M $1 340 612 4.5%
currently when printing a tibble I receive the following output, which is pretty hard to read, especially for the price column:
print(t)
# A tibble: 3 x 3
surface price rate
<dbl> <dbl> <dbl>
1 98000 517244 0.12
2 178000000000 939484 0.07
3 254000000 1340612 0.045
all similar questions found such as here or there seem to revolve around the scientific notation using the options(scipen = xxx)
which doesn't really allow to define the output as desired.
I also tried to look for other packages, such as units but these also don't provide specific number formatting, only attachment of a unit to the column type.