Skip to content

Commit

Permalink
ready for CRAN?
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Jan 4, 2022
1 parent b852195 commit cf652f0
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: datawizard
Title: Easy Data Wrangling
Version: 0.2.1.9001
Version: 0.2.2
Authors@R: c(
person("Dominique", "Makowski", , "dom.makowski@gmail.com", role = "aut",
comment = c(ORCID = "0000-0001-5375-9967", Twitter = "@Dom_Makowski")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# datawizard 0.2.1.9000
# datawizard 0.2.2

- New function `data_extract()` (or its alias `extract()`) to pull single
variables from a data frame, possibly naming each value by the row names
Expand Down
15 changes: 8 additions & 7 deletions R/center.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@ center.numeric <- function(x,
reference = NULL,
center = NULL,
...) {

args <- .process_std_center(x, weights, robust, verbose, reference, center, scale = NULL)

if (is.null(args)) { # all NA?
return(x)
} else if (is.null(args$check)) {
vals <- rep(0, length(args$vals)) # If only unique value
vals <- rep(0, length(args$vals)) # If only unique value
} else {
vals <- as.vector(args$vals - args$center)
}
Expand Down Expand Up @@ -147,8 +146,9 @@ center.data.frame <- function(x,
...) {
# process arguments
args <- .process_std_args(x, select, exclude, weights, append,
append_suffix = "_c", force, remove_na, reference,
.center = center, .scale = NULL)
append_suffix = "_c", force, remove_na, reference,
.center = center, .scale = NULL
)

# set new values
x <- args$x
Expand Down Expand Up @@ -186,9 +186,10 @@ center.grouped_df <- function(x,
append = FALSE,
center = NULL,
...) {

args <- .process_grouped_df(x, select, exclude, append, append_suffix = "_c",
reference, weights, force)
args <- .process_grouped_df(x, select, exclude, append,
append_suffix = "_c",
reference, weights, force
)

for (rows in args$grps) {
args$x[rows, ] <- center(
Expand Down
4 changes: 2 additions & 2 deletions R/data_extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ data_extract.data.frame <- function(data, select, name = NULL, ...) {
name <- rownames(data)
}
if (length(name) == 1) {
stats::setNames(data[,select, drop = TRUE], data[,name, drop = TRUE])
stats::setNames(data[, select, drop = TRUE], data[, name, drop = TRUE])
} else {
stats::setNames(data[,select, drop = TRUE], name)
stats::setNames(data[, select, drop = TRUE], name)
}
}
17 changes: 9 additions & 8 deletions R/standardize.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,13 @@ standardize.numeric <- function(x,
center = NULL,
scale = NULL,
...) {

args <- .process_std_center(x, weights, robust, verbose, reference, center, scale)

# Perform standardization
if (is.null(args)) { # all NA?
return(x)
} else if (is.null(args$check)) {
vals <- rep(0, length(args$vals)) # If only unique value
vals <- rep(0, length(args$vals)) # If only unique value
} else {
if (two_sd) {
vals <- as.vector((args$vals - args$center) / (2 * args$scale))
Expand All @@ -172,7 +171,7 @@ standardize.integer <- standardize.numeric

#' @export
standardize.matrix <- function(x, ...) {
xl <- lapply(seq_len(ncol(x)), function(i) x[,i])
xl <- lapply(seq_len(ncol(x)), function(i) x[, i])

xz <- lapply(xl, datawizard::standardize, ...)

Expand Down Expand Up @@ -239,8 +238,9 @@ standardize.data.frame <- function(x,
...) {
# process arguments
args <- .process_std_args(x, select, exclude, weights, append,
append_suffix = "_z", force, remove_na, reference,
.center = center, .scale = scale)
append_suffix = "_z", force, remove_na, reference,
.center = center, .scale = scale
)

# set new values
x <- args$x
Expand Down Expand Up @@ -283,9 +283,10 @@ standardize.grouped_df <- function(x,
center = NULL,
scale = NULL,
...) {

args <- .process_grouped_df(x, select, exclude, append, append_suffix = "_z",
reference, weights, force)
args <- .process_grouped_df(x, select, exclude, append,
append_suffix = "_z",
reference, weights, force
)

for (rows in args$grps) {
args$x[rows, ] <- standardize(
Expand Down
3 changes: 1 addition & 2 deletions R/unstandardize.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ unstandardize.matrix <- function(x,
centers <- attr(x, "center")

xl <- lapply(seq_len(ncol(x)), function(i) {
tmp <- x[,i]
tmp <- x[, i]
attributes(tmp) <- list(center = centers[i], scale = scales[i])
tmp

})

xz <- lapply(xl, datawizard::unstandardize, ...)
Expand Down
10 changes: 5 additions & 5 deletions R/utils_standardize_center.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
remove_na <- match.arg(remove_na, c("none", "selected", "all"))

omit <- switch(remove_na,
none = logical(nrow(x)),
selected = rowSums(sapply(x[select], is.na)) > 0,
all = rowSums(sapply(x, is.na)) > 0
none = logical(nrow(x)),
selected = rowSums(sapply(x[select], is.na)) > 0,
all = rowSums(sapply(x, is.na)) > 0
)
x <- x[!omit, , drop = FALSE]

Expand Down Expand Up @@ -378,8 +378,8 @@
}
)
if (is.null(model) ||
# prevent self reference
inherits(model, "parameters_model")) {
# prevent self reference
inherits(model, "parameters_model")) {
model <- tryCatch(
{
get(obj_name, envir = globalenv())
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ transform, and prepare your data for analysis.

# Installation

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/datawizard)](https://cran.r-project.org/package=datawizard)
[![datawizard status
badge](https://easystats.r-universe.dev/badges/datawizard)](https://easystats.r-universe.dev)


| Type | Source | Command |
|-------------|------------|------------------------------------------------------------------------------|
| Release | CRAN | `install.packages("datawizard")` |
Expand Down
13 changes: 8 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
## Test environments
* local R installation, R 4.1.1
* ubuntu 16.04 (on github-actions), R 4.1.1
* local R installation, R 4.1.2
* ubuntu 16.04 (on github-actions), R 4.1.2
* win-builder (devel)

## R CMD check results

0 errors | 0 warnings | 0 note

* Maintenance release.
* Maintenance and bug fix release.

## Reverse Dependancies
## revdepcheck results

* No problems detected.
We checked 10 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ rescaling
stackexchange
tailedness
th
tibbles
unitless
untransformed
visualisation
Expand Down
25 changes: 25 additions & 0 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Platform

|field |value |
|:--------|:--------------------------------------------|
|version |R version 4.1.2 (2021-11-01) |
|os |Windows 10 x64 (build 19044) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_United Kingdom.1252 |
|ctype |English_United Kingdom.1252 |
|tz |Europe/Berlin |
|date |2022-01-04 |
|rstudio |2021.09.1+372 Ghost Orchid (desktop) |
|pandoc |2.16.2 @ C:/PROGRA~1/Pandoc/ (via rmarkdown) |

# Dependencies

|package |old |new |<U+0394> |
|:----------|:------|:------|:--|
|datawizard |0.2.1 |0.2.2 |* |
|insight |0.14.5 |0.14.5 | |

# Revdeps

7 changes: 7 additions & 0 deletions revdep/cran.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## revdepcheck results

We checked 10 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages

Binary file added revdep/data.sqlite
Binary file not shown.
1 change: 1 addition & 0 deletions revdep/failures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*Wow, no problems at all. :)*
1 change: 1 addition & 0 deletions revdep/problems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*Wow, no problems at all. :)*
1 change: 0 additions & 1 deletion tests/testthat/test-std_center.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if (require("testthat")) {

d <- iris[1:4, ]

# standardize -----------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-std_center_scale_args.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if (require("testthat")) {

d <- data.frame(a = 1:5, b = 21:25, c = 41:45)

test_that("standardize", {
Expand Down

0 comments on commit cf652f0

Please sign in to comment.