From 9a4f79fa92fcd30c5269f2da0818beeabb10ac63 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Tue, 25 May 2021 18:52:10 +0200 Subject: [PATCH] v1.5.2 --- DESCRIPTION | 4 ++-- NEWS.md | 3 ++- R/freq.R | 4 ++-- R/helpers.R | 4 ++-- docs/404.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 9 +++++---- docs/pkgdown.yml | 2 +- docs/reference/clean.html | 2 +- docs/reference/currency.html | 2 +- docs/reference/format_datetime.html | 8 ++++---- docs/reference/format_names.html | 2 +- docs/reference/format_p_value.html | 2 +- docs/reference/freq.html | 26 +++++++++++++------------- docs/reference/index.html | 2 +- docs/reference/na_replace.html | 4 ++-- docs/reference/percentage.html | 4 ++-- docs/reference/rdate.html | 2 +- docs/reference/regex_true_false.html | 2 +- docs/reference/unclean.html | 2 +- 21 files changed, 46 insertions(+), 44 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 995826a..0a5d95a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cleaner Title: Fast and Easy Data Cleaning -Version: 1.5.1.9000 -Date: 2021-04-12 +Version: 1.5.2 +Date: 2021-05-24 Authors@R: person( given = c("Matthijs", "S."), diff --git a/NEWS.md b/NEWS.md index 0c636c2..5855bc8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ -# cleaner 1.5.1.9000 +# cleaner 1.5.2 +* Fix for latest R-devel, that does not allow `digits = 0` for `format()` * `clean_Date()` now supports month-year format for which it sets the day as 1: ```r clean_Date("March") diff --git a/R/freq.R b/R/freq.R index b31af4b..ceab6d7 100755 --- a/R/freq.R +++ b/R/freq.R @@ -538,7 +538,7 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ", na_txt <- paste0(format(header$na_length, decimal.mark = decimal.mark, big.mark = big.mark), " = ", sub("NaN", "0", percentage(header$na_length / header$length, digits = getdecimalplaces(header$na_length / header$length, - minimum = 0, + minimum = 1, maximum = digits), decimal.mark = decimal.mark), fixed = TRUE)) @@ -554,7 +554,7 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ", header$available <- paste0(format(header$available, decimal.mark = decimal.mark, big.mark = big.mark), " (", trimws(percentage(header$available / header$length, digits = getdecimalplaces(header$available / header$length, - minimum = 0, + minimum = 1, maximum = digits), decimal.mark = decimal.mark)), na_txt, ")") diff --git a/R/helpers.R b/R/helpers.R index 00aaaf9..eafd30e 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -42,7 +42,7 @@ gsub_warn_on_error <- function(pattern, replacement, x, ignore.case = FALSE, per # works exactly like round(), but rounds `round(44.55, 1)` as 44.6 instead of 44.5 # and adds decimal zeroes until `digits` is reached when force_zero = TRUE -round2 <- function(x, digits = 0, force_zero = TRUE) { +round2 <- function(x, digits = 1, force_zero = TRUE) { x <- as.double(x) # https://stackoverflow.com/a/12688836/4575331 val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x) @@ -62,7 +62,7 @@ round2 <- function(x, digits = 0, force_zero = TRUE) { as.double(val) } -getdecimalplaces <- function(x, minimum = 0, maximum = 3) { +getdecimalplaces <- function(x, minimum = 1, maximum = 3) { if (maximum < minimum) { maximum <- minimum } diff --git a/docs/404.html b/docs/404.html index b06c4b8..6ec1a81 100644 --- a/docs/404.html +++ b/docs/404.html @@ -73,7 +73,7 @@ cleaner - 1.5.1.9000 + 1.5.2 diff --git a/docs/authors.html b/docs/authors.html index 53bca53..0a2a968 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -73,7 +73,7 @@ cleaner - 1.5.1.9000 + 1.5.2 diff --git a/docs/index.html b/docs/index.html index 2ef81af..8ab8596 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@ cleaner - 1.5.1.9000 + 1.5.2 diff --git a/docs/news/index.html b/docs/news/index.html index ebc8fb9..ccb8531 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -73,7 +73,7 @@ cleaner - 1.5.1.9000 + 1.5.2 @@ -116,11 +116,12 @@

Changelog

Source: NEWS.md -
-

-cleaner 1.5.1.9000 Unreleased +
+

+cleaner 1.5.2 Unreleased

    +
  • Fix for latest R-devel, that does not allow digits = 0 for format()

  • clean_Date() now supports month-year format for which it sets the day as 1:

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
    index 507f8b1..5973cc1 100644
    --- a/docs/pkgdown.yml
    +++ b/docs/pkgdown.yml
    @@ -2,5 +2,5 @@ pandoc: 2.11.2
     pkgdown: 1.6.1
     pkgdown_sha: ~
     articles: {}
    -last_built: 2021-04-12T09:05Z
    +last_built: 2021-05-24T14:28Z
     
    diff --git a/docs/reference/clean.html b/docs/reference/clean.html
    index 137eb53..9efcea5 100644
    --- a/docs/reference/clean.html
    +++ b/docs/reference/clean.html
    @@ -74,7 +74,7 @@
           
           
             cleaner
    -        1.5.1.9000
    +        1.5.2
           
         
    diff --git a/docs/reference/currency.html b/docs/reference/currency.html index 9437283..5ec560f 100644 --- a/docs/reference/currency.html +++ b/docs/reference/currency.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2
diff --git a/docs/reference/format_datetime.html b/docs/reference/format_datetime.html index 079cf96..f86e8a4 100644 --- a/docs/reference/format_datetime.html +++ b/docs/reference/format_datetime.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2

@@ -142,13 +142,13 @@

Examp
#> [1] "%Y-%m-%d"
# Very hard to remember all these characters: format(Sys.time(), "%a %b %d %Y %X") -
#> [1] "Mon Apr 12 2021 11:05:55"
+
#> [1] "Mon May 24 2021 16:28:08"
# Easy to remember and write the same as above: format(Sys.time(), format_datetime("ddd mmm dd yyyy HH:MM:ss")) -
#> [1] "Mon Apr 12 2021 11:05:55"
+
#> [1] "Mon May 24 2021 16:28:08"
# seconds since the Epoch, 1970-01-01 00:00:00 format(Sys.time(), format_datetime("epoch")) -
#> [1] "1618218355"
+
#> [1] "1621866488"
diff --git a/docs/reference/format_p_value.html b/docs/reference/format_p_value.html index d080ed1..f09ffbd 100644 --- a/docs/reference/format_p_value.html +++ b/docs/reference/format_p_value.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2 diff --git a/docs/reference/freq.html b/docs/reference/freq.html index 804d01f..b9b518b 100644 --- a/docs/reference/freq.html +++ b/docs/reference/freq.html @@ -75,7 +75,7 @@ cleaner - 1.5.1.9000 + 1.5.2 @@ -333,19 +333,19 @@

Examp #> #> Class: character #> Length: 500 -#> Available: 500 (100%, NA: 0 = 0%) +#> Available: 500 (100.0%, NA: 0 = 0.0%) #> Unique: 5 #> #> Shortest: 1 #> Longest: 6 #> -#> Item Count Percent Cum. Count Cum. Percent -#> --- ------- ------ -------- ----------- ------------- -#> 1 male 240 48.0% 240 48.0% -#> 2 female 220 44.0% 460 92.0% -#> 3 man 22 4.4% 482 96.4% -#> 4 m 15 3.0% 497 99.4% -#> 5 F 3 0.6% 500 100.0% +#> Item Count Percent Cum. Count Cum. Percent +#> --- -------- ------- --------- ------------ -------------- +#> 1 male 240 48.0% 240 48.0% +#> 2 female 220 44.0% 460 92.0% +#> 3 man 22 4.4% 482 96.4% +#> 4 m 15 3.0% 497 99.4% +#> 5 F 3 0.6% 500 100.0% #>
freq(x = clean_factor(unclean$gender, levels = c("^m" = "Male", @@ -361,10 +361,10 @@

Examp #> #> #> -#> | |Item | Count| Percent| Cum. Count| Cum. Percent| -#> |:--|:--------|-----:|-------:|----------:|------------:| -#> |1 |"Male" | 277| 55.4%| 277| 55.4%| -#> |2 |"Female" | 223| 44.6%| 500| 100.0%| +#> | |Item | Count| Percent| Cum. Count| Cum. Percent| +#> |:--|:---------|------:|--------:|-----------:|-------------:| +#> |1 |"Male" | 277| 55.4%| 277| 55.4%| +#> |2 |"Female" | 223| 44.6%| 500| 100.0%| #> #>

diff --git a/docs/reference/index.html b/docs/reference/index.html index 257ed02..6e3983a 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -73,7 +73,7 @@ cleaner - 1.5.1.9000 + 1.5.2 diff --git a/docs/reference/na_replace.html b/docs/reference/na_replace.html index 5e55299..85adb4b 100644 --- a/docs/reference/na_replace.html +++ b/docs/reference/na_replace.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2 @@ -180,7 +180,7 @@

Examp
#> [1] 1 2 -1 -1
na_replace(c(1, 2, NA, NA), replacement = c(0, -1))
#> [1] 1 2 0 -1
na_replace(c(Sys.Date(), NA)) # replacement defaults to 'today' -
#> [1] "2021-04-12" "2021-04-12"
+
#> [1] "2021-05-24" "2021-05-24"
na_replace(c(TRUE, FALSE, NA))
#> [1] TRUE FALSE FALSE
na_replace(c(TRUE, FALSE, NA), replacement = TRUE)
#> [1] TRUE FALSE TRUE
diff --git a/docs/reference/percentage.html b/docs/reference/percentage.html index 8cb8f96..781ba95 100644 --- a/docs/reference/percentage.html +++ b/docs/reference/percentage.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2
@@ -161,7 +161,7 @@

Examp proportion
#> [1] 25.00% 250.00% 0.25%
sum(proportion)
#> [1] 275.25%
max(proportion) -
#> [1] 250%
mean(proportion) +
#> [1] 250.0%
mean(proportion)
#> [1] 91.75%
as.percentage(2.5e-14)
#> [1] 0.000%
diff --git a/docs/reference/rdate.html b/docs/reference/rdate.html index 0b4d06b..dd4aa01 100644 --- a/docs/reference/rdate.html +++ b/docs/reference/rdate.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2
diff --git a/docs/reference/regex_true_false.html b/docs/reference/regex_true_false.html index c6e445d..38e8207 100644 --- a/docs/reference/regex_true_false.html +++ b/docs/reference/regex_true_false.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2 diff --git a/docs/reference/unclean.html b/docs/reference/unclean.html index 143f851..89f6a12 100644 --- a/docs/reference/unclean.html +++ b/docs/reference/unclean.html @@ -74,7 +74,7 @@ cleaner - 1.5.1.9000 + 1.5.2