| Type: | Package |
| Title: | Neat Data for Presentation |
| Version: | 0.3.0 |
| Description: | Utilities for unambiguous, neat and legible representation of data (date, time stamp, numbers, percentages and strings) for presentation of analysis , aiming for elegance and consistency. The purpose of this package is to format data, that is better for presentation and any automation jobs that reports numbers. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Imports: | data.table, magrittr, tools |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| RoxygenNote: | 7.3.3 |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-01-31 10:19:06 UTC; shiva |
| Author: | Shivaprakash Suresh [aut, cre, cph] |
| Maintainer: | Shivaprakash Suresh <dswithai@gmail.com> |
| Depends: | R (≥ 4.1.0) |
| Repository: | CRAN |
| Date/Publication: | 2026-01-31 10:50:02 UTC |
Smart format function that infers type and applies neatR formatting.
Description
Smart format function that infers type and applies neatR formatting.
Usage
f(x, format_type = NULL, ...)
Arguments
x |
Input data to format. |
format_type |
Explicit format type: 'day', 'date', 'ts', 'number', 'percent', 'string'. If NULL, type is inferred. |
... |
Additional parameters passed to the underlying formatting functions. |
Value
Formatted string or vector of strings.
neat representation of dates
Description
neat representation of dates
Usage
ndate(
date,
show_weekday = TRUE,
show_month_year = FALSE,
display_weekday = NULL,
is_month = NULL
)
Arguments
date |
a Date or POSIX time stamp |
show_weekday |
a Boolean. Whether the weekday of the date to be included. |
show_month_year |
a Boolean variable representing if the date represents month. If this set to TRUE, the function returns 'MMMM'YY' as the output which is a neater representation of month. |
display_weekday |
Deprecated. Use 'show_weekday' instead. |
is_month |
Deprecated. Use 'show_month_year' instead. |
Value
String representation of the date
Examples
# Neat representation of current date
x <- Sys.Date()
ndate(x)
# Neat representation of current date with day of week.
ndate(x, show_weekday = FALSE)
# Neat representation of current date with only month and year
ndate(x, show_weekday = FALSE, show_month_year = TRUE)
neat alias of the week day with reference based on current date
Description
neat alias of the week day with reference based on current date
Usage
nday(date, show_relative_day = FALSE, reference_alias = NULL)
Arguments
date |
a Date or POSIX time stamp |
show_relative_day |
a Boolean. If set to TRUE, a reference alias of week day is shown based on current date such as Today/Yesterday/Tomorrow/Last/Coming. |
reference_alias |
Deprecated. Use 'show_relative_day' instead. |
Value
week day of the date in a readable format with reference alias based on current date
Examples
# Get day of the week of current date without reference alias
x <- Sys.Date()
nday(x, show_relative_day = FALSE)
# Get day of the week with reference alias
nday(x, show_relative_day = TRUE)
neat representation of numbers
Description
neat representation of numbers
Usage
nnumber(
number,
digits = 1,
unit = "custom",
unit_labels = list(thousand = "K", million = "Mn", billion = "Bn", trillion = "Tn"),
prefix = "",
suffix = "",
thousand_separator = ","
)
Arguments
number |
an integer or double. |
digits |
number of digits to round-off. Default value is 1. |
unit |
unit to which the number to be converted. See examples below. |
unit_labels |
a vector of strings (optional) that gives the unit label for thousand, million, billion and trillion. |
prefix |
a string (optional) that can be prepended to the formatted number. |
suffix |
a string (optional) that can be appended at the end of the formatted number. |
thousand_separator |
a character (optional) that can be used to chunk thousands to display large numbers. Default is set as comma, dot, comma or underscore can be used. |
Value
String representation of numbers with suffix denoting K for thousands,Mn for millions, Bn for billions, Tn for trillions. A number lower than thousand is represented as it is.
Examples
x <- c(
10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000,
1000000000
)
nnumber(x)
nnumber(123456789.123456, digits = 1)
nnumber(123456789.123456, digits = 1, unit = "Mn", prefix = "$")
neat representation of percentage
Description
neat representation of percentage
Usage
npercent(
percent,
is_ratio = TRUE,
digits = 1,
show_plus_sign = TRUE,
show_growth_factor = FALSE,
show_bps = FALSE,
is_decimal = NULL,
plus_sign = NULL,
factor_out = NULL,
basis_points_out = NULL
)
Arguments
percent |
an integer or double representing percentage |
is_ratio |
a Boolean variable. If the percent is raw, the value to set as TRUE. See examples below. If the percent variable is already pre-multiplied by 100 then the value to be set as FALSE. |
digits |
number of digits to round-off |
show_plus_sign |
a Boolean variable. If the percent is positive then setting show_plus_sign = TRUE, includes an explicit + sign before the percent |
show_growth_factor |
an optional Boolean variable. |
show_bps |
an optional parameter to get the percentage as basis points If the percent exceeds |100 readable factors. See examples below. |
is_decimal |
Deprecated. Use 'is_ratio' instead. |
plus_sign |
Deprecated. Use 'show_plus_sign' instead. |
factor_out |
Deprecated. Use 'show_growth_factor' instead. |
basis_points_out |
Deprecated. Use 'show_bps' instead. |
Value
String representation of the percentages.
Examples
# Formatting 22.3%
npercent(0.223, is_ratio = TRUE, digits = 1)
npercent(22.3, is_ratio = FALSE, digits = 1)
# Formatting percentages with growth factors
npercent(c(-4.01, 2.56), is_ratio = TRUE, show_growth_factor = TRUE)
# Formatting percentages as basis points
npercent(
c(-1, -0.5, -0.1, -0.01, 0, 0.01, 0.1, 0.5, 1),
is_ratio = TRUE, show_bps = TRUE
)
neat representation of string
Description
neat representation of string
Usage
nstring(
text,
case = NULL,
remove_specials = FALSE,
keep_chars = "",
ascii_only = FALSE,
string = NULL,
whitelist_specials = NULL,
en_only = NULL
)
Arguments
text |
a string / character |
case |
a string, It specifies how the string should be formatted. Current options are 'lower', 'upper', 'title', 'start' and 'initcap'. |
remove_specials |
a Boolean. If TRUE, special characters are removed from the string. |
keep_chars |
a vector of characters that are kept even if remove_specials is TRUE. |
ascii_only |
a Boolean. If TRUE, only ASCII characters are kept. |
string |
Deprecated. Use 'text' instead. |
whitelist_specials |
Deprecated. Use 'keep_chars' instead. |
en_only |
Deprecated. Use 'ascii_only' instead. |
Value
White space cleaned and optionally formatted by case conversion and removal of special characters of the input string.
Examples
nstring(" All MOdels are wrong. some ARE useful!!! ",
case = "title",
remove_specials = TRUE
)
nstring("all Models are Wrong some are Useful",
case = "start",
remove_specials = TRUE
)
nstring("variable_123!!", remove_specials = TRUE, keep_chars = c("_"))
neat representation of time stamp
Description
neat representation of time stamp
Usage
ntimestamp(
timestamp,
show_weekday = TRUE,
show_date = TRUE,
show_hours = TRUE,
show_minutes = TRUE,
show_seconds = TRUE,
show_timezone = TRUE,
display_weekday = NULL,
include_date = NULL,
include_hours = NULL,
include_minutes = NULL,
include_seconds = NULL,
include_timezone = NULL
)
Arguments
timestamp |
a POSIX time stamp |
show_weekday |
a Boolean representing if the weekday of the timestamp to be included. By default it is set to TRUE |
show_date |
a Boolean representing if the date of time stamp to be included. By default it is set to TRUE. |
show_hours |
a Boolean representing if the hours to be included. By default it is set to TRUE |
show_minutes |
a Boolean representing if the minutes to be included. By default it is set to TRUE |
show_seconds |
a Boolean representing if the seconds to be included. By default it is set to TRUE |
show_timezone |
a Boolean variable representing if the timezone of the date variable to be included. By default it is set to TRUE. |
display_weekday |
Deprecated. Use 'show_weekday' instead. |
include_date |
Deprecated. Use 'show_date' instead. |
include_hours |
Deprecated. Use 'show_hours' instead. |
include_minutes |
Deprecated. Use 'show_minutes' instead. |
include_seconds |
Deprecated. Use 'show_seconds' instead. |
include_timezone |
Deprecated. Use 'show_timezone' instead. |
Value
String representation of time stamp
Examples
# Neat representation of time stamp
x <- Sys.time()
ntimestamp(x)
# Neat representation of time from a time stamp
ntimestamp(x,
show_date = FALSE, show_seconds = FALSE,
show_timezone = FALSE
)
neatR: R package for unambiguous and neat representation of data
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- magrittr