diff --git a/DESCRIPTION b/DESCRIPTION index 1bb6852..906af18 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,7 @@ Suggests: tinytest Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 Collate: 'AllGenerics.R' 'append.R' @@ -47,10 +47,11 @@ Collate: 'discard.R' 'keep.R' 'mathematics.R' + 'palettes.R' 'plot.R' 'remove.R' 'replace.R' - 'scale.R' 'statistics.R' + 'transform.R' 'utilities.R' 'zzz.R' diff --git a/R/AllGenerics.R b/R/AllGenerics.R index 32d193b..16daf92 100644 --- a/R/AllGenerics.R +++ b/R/AllGenerics.R @@ -1,6 +1,6 @@ # GENERIC METHODS -# Data cleaning ================================================================ +# Data preparation ============================================================= ## Count ----------------------------------------------------------------------- #' Count Values Using a Predicate #' @@ -18,7 +18,7 @@ #' @example inst/examples/ex-count.R #' @author N. Frerebeau #' @docType methods -#' @family data cleaning tools +#' @family data preparation tools #' @aliases count-method setGeneric( name = "count", @@ -39,7 +39,7 @@ setGeneric( #' @example inst/examples/ex-detect.R #' @author N. Frerebeau #' @docType methods -#' @family data cleaning tools +#' @family data preparation tools #' @aliases detect-method setGeneric( name = "detect", @@ -56,7 +56,7 @@ setGeneric( #' @example inst/examples/ex-keep.R #' @author N. Frerebeau #' @docType methods -#' @family data cleaning tools +#' @family data preparation tools #' @aliases keep-method setGeneric( name = "keep", @@ -87,7 +87,7 @@ setGeneric( #' @example inst/examples/ex-discard.R #' @author N. Frerebeau #' @docType methods -#' @family data cleaning tools +#' @family data preparation tools #' @aliases discard-method setGeneric( name = "discard", @@ -123,7 +123,7 @@ setGeneric( #' @example inst/examples/ex-compact.R #' @author N. Frerebeau #' @docType methods -#' @family data cleaning tools +#' @family data preparation tools #' @aliases compact-method setGeneric( name = "compact", @@ -144,8 +144,67 @@ setGeneric( def = function(x, ...) standardGeneric("compact_rows") ) -## Remove ---------------------------------------------------------------------- -### NA -------------------------------------------------------------------------- +## Assign ---------------------------------------------------------------------- +#' Assign a Specific Row/Column to the Column/Row Names +#' +#' @param x A [`data.frame`]. +#' @param row A length-one [`numeric`] vector specifying the row number that is +#' to become the column names. +#' @param column A length-one [`numeric`] vector specifying the column number +#' that is to become the row names. +#' @param remove A [`logical`] scalar: should the specified row/column be removed +#' after making it the column/row names? +#' @param ... Currently not used. +#' @example inst/examples/ex-assign.R +#' @return A [`data.frame`]. +#' @author N. Frerebeau +#' @docType methods +#' @family data preparation tools +#' @name assign +#' @rdname assign +NULL + +#' @rdname assign +#' @aliases assign_colnames-method +setGeneric( + name = "assign_colnames", + def = function(x, ...) standardGeneric("assign_colnames") +) + +#' @rdname assign +#' @aliases assign_rownames-method +setGeneric( + name = "assign_rownames", + def = function(x, ...) standardGeneric("assign_rownames") +) + +#' Convert Row Names to an Explicit Column +#' +#' @param x A [`data.frame`]. +#' @param after A length-one [`numeric`] vector specifying a subscript, +#' after which the row names are to be appended. +#' @param var A [`character`] string giving the name of column to use for row +#' names. +#' @param remove A [`logical`] scalar: should the row names be removed? +#' @param ... Currently not used. +#' @example inst/examples/ex-assign.R +#' @return A [`data.frame`]. +#' @author N. Frerebeau +#' @docType methods +#' @family data preparation tools +#' @name append +#' @rdname append +NULL + +#' @rdname append +#' @aliases append_rownames-method +setGeneric( + name = "append_rownames", + def = function(x, ...) standardGeneric("append_rownames") +) + +# Data cleaning ================================================================ +## NA -------------------------------------------------------------------------- #' Tools for Working With Missing Values #' #' @description @@ -178,7 +237,7 @@ setGeneric( def = function(x, ...) standardGeneric("replace_NA") ) -### Inf ------------------------------------------------------------------------- +## Inf ------------------------------------------------------------------------- #' Tools for Working With Infinite Values #' #' @description @@ -211,7 +270,7 @@ setGeneric( def = function(x, ...) standardGeneric("replace_Inf") ) -### Zeros ----------------------------------------------------------------------- +## Zeros ----------------------------------------------------------------------- #' Tools for Working With Zeros #' #' @description @@ -244,7 +303,7 @@ setGeneric( def = function(x, ...) standardGeneric("replace_zero") ) -### Empty string --------------------------------------------------------------- +## Empty string ---------------------------------------------------------------- #' Tools for Working With Empty String #' #' @description @@ -277,7 +336,7 @@ setGeneric( def = function(x, ...) standardGeneric("replace_empty") ) -### Constant ------------------------------------------------------------------- +## Constant -------------------------------------------------------------------- #' Remove Constant Columns #' #' @param x An \R object (should be a [`matrix`] or a [`data.frame`]). @@ -297,65 +356,6 @@ setGeneric( ) # Data transformation ========================================================== -## Assign ---------------------------------------------------------------------- -#' Assign a Specific Row/Column to the Column/Row Names -#' -#' -#' @param x A [`data.frame`]. -#' @param row A length-one [`numeric`] vector specifying the row number that is -#' to become the column names. -#' @param column A length-one [`numeric`] vector specifying the column number -#' that is to become the row names. -#' @param remove A [`logical`] scalar: should the specified row/column be removed -#' after making it the column/row names? -#' @param ... Currently not used. -#' @example inst/examples/ex-assign.R -#' @return A [`data.frame`]. -#' @author N. Frerebeau -#' @docType methods -#' @family transformation tools -#' @name assign -#' @rdname assign -NULL - -#' @rdname assign -#' @aliases assign_colnames-method -setGeneric( - name = "assign_colnames", - def = function(x, ...) standardGeneric("assign_colnames") -) - -#' @rdname assign -#' @aliases assign_rownames-method -setGeneric( - name = "assign_rownames", - def = function(x, ...) standardGeneric("assign_rownames") -) - -#' Convert Row Names to an Explicit Column -#' -#' @param x A [`data.frame`]. -#' @param after A length-one [`numeric`] vector specifying a subscript, -#' after which the row names are to be appended. -#' @param var A [`character`] string giving the name of column to use for row -#' names. -#' @param remove A [`logical`] scalar: should the row names be removed? -#' @param ... Currently not used. -#' @example inst/examples/ex-assign.R -#' @return A [`data.frame`]. -#' @author N. Frerebeau -#' @docType methods -#' @family transformation tools -#' @name append -#' @rdname append -NULL - -#' @rdname append -#' @aliases append_rownames-method -setGeneric( - name = "append_rownames", - def = function(x, ...) standardGeneric("append_rownames") -) # Mathematics ================================================================== #' Least Common Multiple @@ -506,6 +506,7 @@ setGeneric( def = function(object, ...) standardGeneric("confidence_multinomial") ) +# Resampling =================================================================== ## Bootstrap ------------------------------------------------------------------- #' Bootstrap Estimation #' diff --git a/R/scale.R b/R/palettes.R similarity index 88% rename from R/scale.R rename to R/palettes.R index 24f3fb7..774dd63 100644 --- a/R/scale.R +++ b/R/palettes.R @@ -1,19 +1,4 @@ -# SCALE -NULL - -#' Rescale Continuous Vector -#' -#' Rescales continuous vector to have specified minimum and maximum. -#' @param x A [`numeric`] vector. -#' @param to A length-two [`numeric`] vector specifying the output range. -#' @param from A length-two [`numeric`] vector specifying the input range. -#' @note For internal use only. -#' @return A [`numeric`] vector. -#' @family scales -#' @export -scale_range <- function(x, to = c(0, 1), from = range(x, finite = TRUE)) { - (x - from[1L]) / diff(from) * diff(to) + to[1L] -} +# PALETTES #' Color Mapping #' diff --git a/R/transform.R b/R/transform.R new file mode 100644 index 0000000..9422ce3 --- /dev/null +++ b/R/transform.R @@ -0,0 +1,16 @@ +# DATA TRANSFORMATION +NULL + +#' Rescale Continuous Vector +#' +#' Rescales continuous vector to have specified minimum and maximum. +#' @param x A [`numeric`] vector. +#' @param to A length-two [`numeric`] vector specifying the output range. +#' @param from A length-two [`numeric`] vector specifying the input range. +#' @note For internal use only. +#' @return A [`numeric`] vector. +#' @family data transformation tools +#' @export +scale_range <- function(x, to = c(0, 1), from = range(x, finite = TRUE)) { + (x - from[1L]) / diff(from) * diff(to) + to[1L] +} diff --git a/man/append.Rd b/man/append.Rd index 39b5e4e..d94ddad 100644 --- a/man/append.Rd +++ b/man/append.Rd @@ -45,10 +45,15 @@ X <- data.frame( (Z <- append_rownames(Y)) } \seealso{ -Other transformation tools: -\code{\link{assign}()} +Other data preparation tools: +\code{\link{assign}()}, +\code{\link{compact}()}, +\code{\link{count}()}, +\code{\link{detect}()}, +\code{\link{discard}()}, +\code{\link{keep}()} } \author{ N. Frerebeau } -\concept{transformation tools} +\concept{data preparation tools} diff --git a/man/arkhe-package.Rd b/man/arkhe-package.Rd index 16c6677..2360b55 100644 --- a/man/arkhe-package.Rd +++ b/man/arkhe-package.Rd @@ -3,7 +3,6 @@ \docType{package} \name{arkhe-package} \alias{arkhe-package} -\alias{_PACKAGE} \alias{arkhe} \title{arkhe: Tools for Cleaning Rectangular Data} \description{ diff --git a/man/assign.Rd b/man/assign.Rd index 124ee46..3a537bb 100644 --- a/man/assign.Rd +++ b/man/assign.Rd @@ -53,10 +53,15 @@ X <- data.frame( (Z <- append_rownames(Y)) } \seealso{ -Other transformation tools: -\code{\link{append}()} +Other data preparation tools: +\code{\link{append}()}, +\code{\link{compact}()}, +\code{\link{count}()}, +\code{\link{detect}()}, +\code{\link{discard}()}, +\code{\link{keep}()} } \author{ N. Frerebeau } -\concept{transformation tools} +\concept{data preparation tools} diff --git a/man/compact.Rd b/man/compact.Rd index 71c38d7..64fed59 100644 --- a/man/compact.Rd +++ b/man/compact.Rd @@ -57,18 +57,15 @@ compact(X, margin = 2) \seealso{ \code{\link[=remove_NA]{remove_NA()}}, \code{\link[=remove_zero]{remove_zero()}}, \code{\link[=remove_empty]{remove_empty()}} -Other data cleaning tools: +Other data preparation tools: +\code{\link{append}()}, +\code{\link{assign}()}, \code{\link{count}()}, \code{\link{detect}()}, \code{\link{discard}()}, -\code{\link{empty}}, -\code{\link{infinite}}, -\code{\link{keep}()}, -\code{\link{missing}}, -\code{\link{remove_constant}()}, -\code{\link{zero}} +\code{\link{keep}()} } \author{ N. Frerebeau } -\concept{data cleaning tools} +\concept{data preparation tools} diff --git a/man/count.Rd b/man/count.Rd index 583b1da..39697bb 100644 --- a/man/count.Rd +++ b/man/count.Rd @@ -51,18 +51,15 @@ count(X, f = is.na, margin = 1) count(X, f = is.na, margin = 2, negate = TRUE) } \seealso{ -Other data cleaning tools: +Other data preparation tools: +\code{\link{append}()}, +\code{\link{assign}()}, \code{\link{compact}()}, \code{\link{detect}()}, \code{\link{discard}()}, -\code{\link{empty}}, -\code{\link{infinite}}, -\code{\link{keep}()}, -\code{\link{missing}}, -\code{\link{remove_constant}()}, -\code{\link{zero}} +\code{\link{keep}()} } \author{ N. Frerebeau } -\concept{data cleaning tools} +\concept{data preparation tools} diff --git a/man/detect.Rd b/man/detect.Rd index f69deb1..61967ba 100644 --- a/man/detect.Rd +++ b/man/detect.Rd @@ -53,18 +53,15 @@ detect(X, f = is.na, margin = 1) detect(X, f = is.na, margin = 2, negate = TRUE, all = TRUE) } \seealso{ -Other data cleaning tools: +Other data preparation tools: +\code{\link{append}()}, +\code{\link{assign}()}, \code{\link{compact}()}, \code{\link{count}()}, \code{\link{discard}()}, -\code{\link{empty}}, -\code{\link{infinite}}, -\code{\link{keep}()}, -\code{\link{missing}}, -\code{\link{remove_constant}()}, -\code{\link{zero}} +\code{\link{keep}()} } \author{ N. Frerebeau } -\concept{data cleaning tools} +\concept{data preparation tools} diff --git a/man/discard.Rd b/man/discard.Rd index f8e14fd..fc699d4 100644 --- a/man/discard.Rd +++ b/man/discard.Rd @@ -92,18 +92,15 @@ discard(X, f = is.na, margin = 1, all = FALSE) discard(X, f = is.na, margin = 2, all = FALSE) } \seealso{ -Other data cleaning tools: +Other data preparation tools: +\code{\link{append}()}, +\code{\link{assign}()}, \code{\link{compact}()}, \code{\link{count}()}, \code{\link{detect}()}, -\code{\link{empty}}, -\code{\link{infinite}}, -\code{\link{keep}()}, -\code{\link{missing}}, -\code{\link{remove_constant}()}, -\code{\link{zero}} +\code{\link{keep}()} } \author{ N. Frerebeau } -\concept{data cleaning tools} +\concept{data preparation tools} diff --git a/man/empty.Rd b/man/empty.Rd index 913c47d..84bb5d3 100644 --- a/man/empty.Rd +++ b/man/empty.Rd @@ -63,12 +63,7 @@ replace_empty(X, value = "XXX") } \seealso{ Other data cleaning tools: -\code{\link{compact}()}, -\code{\link{count}()}, -\code{\link{detect}()}, -\code{\link{discard}()}, \code{\link{infinite}}, -\code{\link{keep}()}, \code{\link{missing}}, \code{\link{remove_constant}()}, \code{\link{zero}} diff --git a/man/infinite.Rd b/man/infinite.Rd index 1958c7e..4ffcc70 100644 --- a/man/infinite.Rd +++ b/man/infinite.Rd @@ -63,12 +63,7 @@ replace_Inf(X, value = 0) } \seealso{ Other data cleaning tools: -\code{\link{compact}()}, -\code{\link{count}()}, -\code{\link{detect}()}, -\code{\link{discard}()}, \code{\link{empty}}, -\code{\link{keep}()}, \code{\link{missing}}, \code{\link{remove_constant}()}, \code{\link{zero}} diff --git a/man/keep.Rd b/man/keep.Rd index edc7670..ebe4669 100644 --- a/man/keep.Rd +++ b/man/keep.Rd @@ -92,18 +92,15 @@ keep(X, f = is.na, margin = 1, negate = TRUE, all = TRUE) keep(X, f = is.na, margin = 2, negate = TRUE, all = TRUE) } \seealso{ -Other data cleaning tools: +Other data preparation tools: +\code{\link{append}()}, +\code{\link{assign}()}, \code{\link{compact}()}, \code{\link{count}()}, \code{\link{detect}()}, -\code{\link{discard}()}, -\code{\link{empty}}, -\code{\link{infinite}}, -\code{\link{missing}}, -\code{\link{remove_constant}()}, -\code{\link{zero}} +\code{\link{discard}()} } \author{ N. Frerebeau } -\concept{data cleaning tools} +\concept{data preparation tools} diff --git a/man/missing.Rd b/man/missing.Rd index bdda2ce..7cdf33e 100644 --- a/man/missing.Rd +++ b/man/missing.Rd @@ -63,13 +63,8 @@ replace_NA(X, value = 0) } \seealso{ Other data cleaning tools: -\code{\link{compact}()}, -\code{\link{count}()}, -\code{\link{detect}()}, -\code{\link{discard}()}, \code{\link{empty}}, \code{\link{infinite}}, -\code{\link{keep}()}, \code{\link{remove_constant}()}, \code{\link{zero}} } diff --git a/man/palette_color.Rd b/man/palette_color.Rd index d747f37..7691cf7 100644 --- a/man/palette_color.Rd +++ b/man/palette_color.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale.R +% Please edit documentation in R/palettes.R \name{palette_color} \alias{palette_color} \alias{palette_color_continuous} diff --git a/man/palette_shape.Rd b/man/palette_shape.Rd index 0202871..ad01594 100644 --- a/man/palette_shape.Rd +++ b/man/palette_shape.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale.R +% Please edit documentation in R/palettes.R \name{palette_shape} \alias{palette_shape} \title{Symbol Mapping} diff --git a/man/palette_size.Rd b/man/palette_size.Rd index 8e46b6d..0db7999 100644 --- a/man/palette_size.Rd +++ b/man/palette_size.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale.R +% Please edit documentation in R/palettes.R \name{palette_size} \alias{palette_size} \title{Symbol Size Mapping} diff --git a/man/remove_constant.Rd b/man/remove_constant.Rd index ee800b9..50cd81a 100644 --- a/man/remove_constant.Rd +++ b/man/remove_constant.Rd @@ -39,13 +39,8 @@ remove_constant(X, na.rm = TRUE) } \seealso{ Other data cleaning tools: -\code{\link{compact}()}, -\code{\link{count}()}, -\code{\link{detect}()}, -\code{\link{discard}()}, \code{\link{empty}}, \code{\link{infinite}}, -\code{\link{keep}()}, \code{\link{missing}}, \code{\link{zero}} } diff --git a/man/scale_range.Rd b/man/scale_range.Rd index 035cec5..03138b9 100644 --- a/man/scale_range.Rd +++ b/man/scale_range.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale.R +% Please edit documentation in R/transform.R \name{scale_range} \alias{scale_range} \title{Rescale Continuous Vector} @@ -22,4 +22,4 @@ Rescales continuous vector to have specified minimum and maximum. \note{ For internal use only. } -\concept{scales} +\concept{data transformation tools} diff --git a/man/zero.Rd b/man/zero.Rd index fa25018..4f8e053 100644 --- a/man/zero.Rd +++ b/man/zero.Rd @@ -63,13 +63,8 @@ replace_zero(X, value = 1) } \seealso{ Other data cleaning tools: -\code{\link{compact}()}, -\code{\link{count}()}, -\code{\link{detect}()}, -\code{\link{discard}()}, \code{\link{empty}}, \code{\link{infinite}}, -\code{\link{keep}()}, \code{\link{missing}}, \code{\link{remove_constant}()} } diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 41221c4..15ca872 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -4,21 +4,15 @@ template: package: tekton reference: -- title: Data cleaning +- title: Data Preparation + contents: + - has_concept("data preparation tools") +- title: Data Cleaning contents: - has_concept("data cleaning tools") - title: Data transformation contents: - - has_concept("transformation tools") -- title: Scales - contents: - - has_concept("scales") -- title: Predicates - contents: - - has_concept("predicates") -- title: Validation - contents: - - has_concept("validation methods") + - has_concept("data transformation tools") - title: Statistics contents: - has_concept("summary statistics") @@ -31,6 +25,12 @@ reference: - title: Palettes contents: - has_concept("palettes") +- title: Predicates + contents: + - has_concept("predicates") +- title: Validation + contents: + - has_concept("validation methods") - title: Utilities contents: - has_concept("utilities")