Skip to content

Commit

Permalink
Incorrect S4 methods fix
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed May 28, 2020
1 parent 9269337 commit cc6e8ae
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 129 deletions.
2 changes: 1 addition & 1 deletion 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.4.0.9000
Date: 2020-04-23
Date: 2020-05-28
Authors@R:
person(
given = c("Matthijs", "S."),
Expand Down
61 changes: 0 additions & 61 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -92,67 +92,6 @@ export(rdate)
export(regex_false)
export(regex_true)
export(top_freq)
exportMethods("[.currency")
exportMethods("[.percentage")
exportMethods("[<-.currency")
exportMethods("[<-.percentage")
exportMethods("[[.currency")
exportMethods("[[.percentage")
exportMethods("[[<-.currency")
exportMethods("[[<-.percentage")
exportMethods(as.data.frame.freq)
exportMethods(as.double.percentage)
exportMethods(as.vector.freq)
exportMethods(boxplot.freq)
exportMethods(c.currency)
exportMethods(c.percentage)
exportMethods(clean)
exportMethods(clean.data.frame)
exportMethods(clean.default)
exportMethods(format.currency)
exportMethods(format.freq)
exportMethods(format.percentage)
exportMethods(freq)
exportMethods(freq.Date)
exportMethods(freq.POSIXt)
exportMethods(freq.character)
exportMethods(freq.data.frame)
exportMethods(freq.default)
exportMethods(freq.difftime)
exportMethods(freq.double)
exportMethods(freq.hms)
exportMethods(freq.integer)
exportMethods(freq.list)
exportMethods(freq.matrix)
exportMethods(freq.numeric)
exportMethods(freq.table)
exportMethods(hist.freq)
exportMethods(max.currency)
exportMethods(max.percentage)
exportMethods(mean.currency)
exportMethods(mean.percentage)
exportMethods(median.currency)
exportMethods(median.percentage)
exportMethods(min.currency)
exportMethods(min.percentage)
exportMethods(na_replace)
exportMethods(na_replace.Date)
exportMethods(na_replace.character)
exportMethods(na_replace.data.frame)
exportMethods(na_replace.default)
exportMethods(na_replace.integer)
exportMethods(na_replace.list)
exportMethods(na_replace.logical)
exportMethods(na_replace.matrix)
exportMethods(na_replace.numeric)
exportMethods(plot.freq)
exportMethods(print.currency)
exportMethods(print.freq)
exportMethods(print.percentage)
exportMethods(sum.currency)
exportMethods(sum.percentage)
exportMethods(summary.currency)
exportMethods(summary.percentage)
importFrom(crayon,bold)
importFrom(crayon,green)
importFrom(crayon,red)
Expand Down
5 changes: 2 additions & 3 deletions R/clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
#' \item{\code{clean_POSIXct()}: classes \code{POSIXct/POSIXt}}
#' }
#' @export
#' @exportMethod clean
#' @source \href{http://www.bis.org/publ/rpfx16fx.pdf}{Triennial Central Bank Survey Foreign exchange turnover in April 2016} (PDF). Bank for International Settlements. 11 December 2016. p. 10.
#' @examples
#' clean_logical(c("Yes", "No")) # English
Expand Down Expand Up @@ -125,7 +124,7 @@ clean <- function(x) {
UseMethod("clean")
}

#' @exportMethod clean.default
#' @method clean default
#' @export
#' @noRd
clean.default <- function(x, ...) {
Expand Down Expand Up @@ -158,7 +157,7 @@ clean.default <- function(x, ...) {
fn_winner(x)
}

#' @exportMethod clean.data.frame
#' @method clean data.frame
#' @export
#' @rdname clean
clean.data.frame <- function(x) {
Expand Down
26 changes: 13 additions & 13 deletions R/currency.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,39 @@ is.currency <- function(x) {
identical(class(x), c("currency", "numeric"))
}

#' @exportMethod [.currency
#' @method [ currency
#' @export
#' @noRd
"[.currency" <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
}
#' @exportMethod [<-.currency
#' @method [<- currency
#' @export
#' @noRd
"[<-.currency" <- function(value) {
y <- NextMethod()
attributes(y) <- attributes(value)
y
}
#' @exportMethod [[.currency
#' @method [[ currency
#' @export
#' @noRd
"[[.currency" <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
}
#' @exportMethod [[<-.currency
#' @method [[<- currency
#' @export
#' @noRd
"[[<-.currency" <- function(value) {
y <- NextMethod()
attributes(y) <- attributes(value)
y
}
#' @exportMethod c.currency
#' @method c currency
#' @export
#' @noRd
c.currency <- function(x, ...) {
Expand All @@ -107,7 +107,7 @@ txt2symb <- function(txt) {
}

#' @rdname currency
#' @exportMethod print.currency
#' @method print currency
#' @export
print.currency <- function(x,
decimal.mark = getOption("OutDec"),
Expand All @@ -131,7 +131,7 @@ print.currency <- function(x,
}

#' @rdname currency
#' @exportMethod format.currency
#' @method format currency
#' @export
format.currency <- function(x,
currency_symbol = attributes(x)$currency_symbol,
Expand All @@ -154,43 +154,43 @@ format.currency <- function(x,
}

#' @noRd
#' @exportMethod sum.currency
#' @method sum currency
#' @export
sum.currency <- function(x, ...) {
as.currency(sum(as.numeric(x), ...), currency_symbol = attributes(x)$currency_symbol)
}

#' @noRd
#' @exportMethod min.currency
#' @method min currency
#' @export
min.currency <- function(x, ...) {
as.currency(min(as.numeric(x), ...), currency_symbol = attributes(x)$currency_symbol)
}

#' @noRd
#' @exportMethod max.currency
#' @method max currency
#' @export
max.currency <- function(x, ...) {
as.currency(max(as.numeric(x), ...), currency_symbol = attributes(x)$currency_symbol)
}

#' @noRd
#' @exportMethod mean.currency
#' @method mean currency
#' @export
mean.currency <- function(x, ...) {
as.currency(mean(as.numeric(x), ...), currency_symbol = attributes(x)$currency_symbol)
}

#' @noRd
#' @exportMethod median.currency
#' @method median currency
#' @importFrom stats median
#' @export
median.currency <- function(x, ...) {
as.currency(median(as.numeric(x), ...), currency_symbol = attributes(x)$currency_symbol)
}

#' @noRd
#' @exportMethod summary.currency
#' @method summary currency
#' @export
summary.currency <- function(object, ...) {
c("Class" = paste0("currency", txt2symb(trimws(attributes(object)$currency_symbol))),
Expand Down
5 changes: 4 additions & 1 deletion R/format_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ format_names <- function(x,
current <- gsub("[^a-zA-Z0-9]+", "", current)
current <- gsub("^(.)", "\\L\\1", current, perl = TRUE)
} else if (isTRUE(snake_case)) {
current <- tolower(gsub("[^a-zA-Z0-9]+", "_", current))
current <- gsub("[^a-zA-Z0-9]+", "_", current)
current <- gsub("([a-z0-9])([A-Z])", "\\1_\\2", current)
current <- gsub("([a-zA-Z])([0-9])", "\\1_\\2", current)
current <- tolower(current)
}

if (isTRUE(toupper)) {
Expand Down
Loading

0 comments on commit cc6e8ae

Please sign in to comment.