dfe-analytical-services / dfeR

Common R tasks in the Department for Education (DfE)
https://dfe-analytical-services.github.io/dfeR/
GNU General Public License v3.0
9 stars 2 forks source link

Add pretty_* suite of functions #69

Closed cjrace closed 6 months ago

cjrace commented 6 months ago

Brief overview of changes

Add a suite of pretty_* functions for neatly presenting data values (big numbers, time references and file sizes).

Why are these changes being made?

We use these functions in a number of places and sometimes even write multiple versions in a single repo, so having some standardised ones would be helpful and save time.

It's also been a useful process as it's allowed me to QA some code I wrote years ago in other projects that had questionable maths in it...

Detailed description of changes

  1. Add 4 new functions - comma_sep(), pretty_filesize(), pretty_num(), pretty_time_taken().

comma_sep() is the same as cs_num() that appears a lot in our repos, it's mainly a helper function that's reused in this package, and I imagine people may mainly use pretty_num() instead, but exported it as some may find it useful in isolation too.

pretty_num() is an attempted rework of fmtRdble() and other incarnations, which takes comma_sep() and also rounds / adds prefixes and suffixes to big numbers as well as converting to million and billion in text.

pretty_filesize() and pretty_time_taken() are mainly based on functions from the old analytics app and the data screener.

  1. Some minor updates to the contributing page, including shortcuts for roxygen2

  2. Bumps the package version to 0.3.0 as there's new features

Additional information for reviewers

Git history seems to be messy / duplicative of #68, will squash this into a single commit when it goes in.

Issue ticket number/s and link

Resolves #64 #60

cjrace commented 6 months ago

add format readable / prettier functions into dfeR