Skip to content

Commit

Permalink
v1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed Oct 30, 2022
1 parent 8b6f780 commit 3fa67f7
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 21 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
^cran-comments\.md$
^lintr\.R$
^.github$
^CRAN-SUBMISSION$
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 1.5.4
Date: 2022-10-28 13:00:25 UTC
SHA: 8b6f7806f6cad942907166ec76ea256667f1e23f
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cleaner
Title: Fast and Easy Data Cleaning
Version: 1.5.3.9003
Date: 2022-10-24
Version: 1.5.4
Date: 2022-10-28
Authors@R:
person(
given = c("Matthijs", "S."),
Expand All @@ -27,7 +27,7 @@ Suggests:
ggplot2,
rmarkdown,
testthat (>= 1.0.2)
URL: https://github.com/msberends/cleaner
URL: https://msberends.github.io/cleaner/, https://github.com/msberends/cleaner
BugReports: https://github.com/msberends/cleaner/issues
License: GPL-2
Encoding: UTF-8
Expand Down
15 changes: 13 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# cleaner 1.5.3.9xxx
# cleaner 1.5.4

* Fix for `digits` in `format()`
* For `clean_Date()` and `clean_POSIXct()`: allow argument `max_date` to be the same length as `x`
* Fix for `digits` in `format()`
* Fix for currency symbols
* Fix CRAN check error


# cleaner 1.5.3

Expand All @@ -23,6 +26,7 @@
* `freq()` now contains a `wt` argument to set the weights. The default (`NULL`) yields the old behaviour.
* Fixed a bug in `clean_POSIXct()` that led to the warning `Incompatible methods ("Ops.POSIXt", "Ops.Date") for ">"`


# cleaner 1.5.1

* New function `format_p_value()` to format raw p values according to the APA guideline
Expand All @@ -34,6 +38,7 @@
* Currency now prints and formats without symbols as default, use `as_symbol = TRUE` to print/format with currency symbols
* Support for older versions of R (v3.2)


# cleaner 1.5.0

* New function `format_names()` to quickly and easily change names of `data.frame` columns, `list`s or `character` vectors.
Expand Down Expand Up @@ -66,6 +71,7 @@
```
* Support for the upcoming R 4.1.0


# cleaner 1.4.0

* New function `rdate()` to generate random dates (in analogy to e.g. `runif()`)
Expand Down Expand Up @@ -100,18 +106,21 @@
```
* Cleaned all code using the `lintr` package


# cleaner 1.3.1

* Fixed a bug when using a `percentage` class into the `percentage()` function, i.e. `percentage(as.percentage(1))` would fail
* Fixed extremely small percentages, like `as.percentage(2.5e-14)`


# cleaner 1.3.0

* Added functions `clean_double()` and `clean_integer()`
* Added a method for `median()` in percentages
* Fixed a bug where `NA` in percentages would not be formatted correctly
* Fixed a bug in frequency tables where sometimes the number of digits used for percentages would be astronomical


# cleaner 1.2.0

* **DUE TO CRAN POLICY: RENAMED TO PACKAGE TO `cleaner`**
Expand All @@ -121,6 +130,7 @@
* Fix for `clean_character()` on R v3.5 and lower
* Fix for digits in frequency tables for numeric values


# clean 1.1.0

* Added support for currency as a new class: `as.currency()` and `clean_currency()`. They also come with 'S3 methods' for `print`, `format`, `sum`, `min` and `max`.
Expand All @@ -132,6 +142,7 @@
* `clean_numeric()` now supports currency
* Fix for `freq()` where the precentage of NAs in the header was not calculated right


# clean 1.0.0

* First release
31 changes: 16 additions & 15 deletions R/currency.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ c.currency <- function(x, ...) {
}

txt2symb <- function(txt) {
switch(txt,
"USD" = "\u0024",
"EUR" = "\u20ac",
"JPY" = "\u00a5",
"GBP" = "\u00a3",
txt)
}

symb2txt <- function(txt) {
switch(txt,
"\u0024" = "USD",
"\u20ac" = "EUR",
"\u00a5" = "JPY",
"\u00a3" = "GBP",
txt)
txt <- toupper(txt)
sym <- unname(pkg_env$symbols[which(names(pkg_env$symbols) == txt)])
if (length(sym) == 0) {
txt
} else {
sym
}
}

symb2txt <- function(sym) {
txt <- unname(names(pkg_env$symbols)[which(pkg_env$symbols == sym)])
if (length(txt) == 0) {
sym
} else {
txt
}
}

#' @rdname currency
Expand Down
8 changes: 8 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
# ==================================================================== #

pkg_env <- new.env(hash = FALSE)
.onLoad <- function(libname, pkgname) {
backports::import(pkgname)
# read symbols from external file to prevent CRAN errors
symbols <- tryCatch(utils::read.delim(system.file("symbols.txt", package = "cleaner"), sep = ","), error = function(e) NULL)
if (!is.null(symbols)) {
pkg_env$symbols <- stats::setNames(symbols$symbol, symbols$txt)
} else {
pkg_env$symbols <- character(0)
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Contents:
----

## Why this package
As a data scientist, I'm often served with data that is not clean, not tidy and consequently not ready for analysis at all. For tidying data, there's of course the `tidyverse` (https://www.tidyverse.org), which lets you manipulate data in any way you can think of. But for *cleaning*, I think our community was still lacking a neat solution that makes data cleaning fast and easy with functions that kind of 'think on their own' to do that.
You are probably often served with data that is not clean, not tidy and consequently not ready for analysis at all. For tidying data, there's of course the `tidyverse` (https://www.tidyverse.org), which lets you manipulate data in any way you can think of. But for *cleaning*, our community might still have been lacking a neat solution that makes data cleaning fast and easy with functions that kind of 'think on their own' to do that.

If the CRAN button at the top of this page is green, install the package with:

Expand Down
7 changes: 7 additions & 0 deletions inst/symbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
txt,symbol
"CNY","元"
"EUR","€"
"GBP","£"
"JPY","¥"
"KRW","₩"
"USD","$"
1 change: 1 addition & 0 deletions tests/testthat/test-currency.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ context("currency.R")

test_that("currency works", {
expect_true(is.currency(clean_currency(c("no5538", "no929", "yes2390", "no841", "no2610"))))
expect_identical(symb2txt(txt2symb("EUR")), "EUR")
})

0 comments on commit 3fa67f7

Please sign in to comment.