Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove arguments deprecated in 0.5.0 #487

Merged
merged 7 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# datawizard 0.9.2

BREAKING CHANGES

* The following arguments were deprecated in 0.5.0 and are now removed:

* in `data_to_wide()`: `colnames_from`, `rows_from`, `sep`
* in `data_to_long()`: `colnames_to`
* in `data_partition()`: `training_proportion`

NEW FUNCTIONS

* `data_summary()`, to compute summary statistics of (grouped) data frames.
Expand All @@ -13,7 +21,7 @@ CHANGES
argument, to compute weighted frequency tables. `include_na` allows to include
or omit missing values from the table. Furthermore, a `by` argument was added,
to compute crosstables (#479, #481).

# datawizard 0.9.1

CHANGES
Expand Down Expand Up @@ -121,7 +129,7 @@ CHANGES
(similar to other data frame methods of transformation functions), to append
recoded variables to the input data frame instead of overwriting existing
variables.

NEW FUNCTIONS

* `rowid_as_column()` to complement `rownames_as_column()` (and to mimic
Expand Down
2 changes: 0 additions & 2 deletions R/data_partition.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @param proportion Scalar (between 0 and 1) or numeric vector, indicating the
#' proportion(s) of the training set(s). The sum of `proportion` must not be
#' greater than 1. The remaining part will be used for the test set.
#' @param training_proportion Deprecated, please use `proportion`.
#' @param group A character vector indicating the name(s) of the column(s) used
#' for stratified partitioning.
#' @param seed A random number generator seed. Enter an integer (e.g. 123) so
Expand Down Expand Up @@ -50,7 +49,6 @@
seed = NULL,
row_id = ".row_id",
verbose = TRUE,
training_proportion = proportion,
...) {
# validation checks
data <- .coerce_to_dataframe(data)
Expand Down Expand Up @@ -132,7 +130,7 @@
})

# we need to move all list elements one level higher.
if (!is.null(group)) {

Check warning on line 133 in R/data_partition.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_partition.R,line=133,col=7,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
# for grouped training sets, we need to row-bind all sampled training
# sets from each group. currently, we have a list of data frames,
# grouped by "group"; but we want one data frame per proportion that
Expand All @@ -151,7 +149,7 @@
# remove all training set id's from data, add remaining data (= test set)
out <- c(
training_sets,
list(test = data[-unlist(lapply(training_sets, data_extract, select = row_id, as_data_frame = FALSE), use.names = FALSE), ])

Check warning on line 152 in R/data_partition.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_partition.R,line=152,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 128 characters.
)

lapply(out, `row.names<-`, NULL)
Expand Down
11 changes: 1 addition & 10 deletions R/data_to_long.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#' @param cols Identical to `select`. This argument is here to ensure compatibility
#' with `tidyr::pivot_longer()`. If both `select` and `cols` are provided, `cols`
#' is used.
#' @param colnames_to Deprecated. Use `names_to` instead.
#'
#' @return If a tibble was provided as input, `reshape_longer()` also returns a
#' tibble. Otherwise, it returns a data frame.
Expand Down Expand Up @@ -78,18 +77,10 @@
ignore_case = FALSE,
regex = FALSE,
...,
cols,
colnames_to) {
# Check args
if (!missing(colnames_to)) {
.is_deprecated("colnames_to", "names_to")
if (is.null(names_to)) {
names_to <- colnames_to
}
}
cols) {

Check warning on line 80 in R/data_to_long.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_long.R,line=80,col=26,[function_argument_linter] Arguments without defaults should come before arguments with defaults. Consider setting the default to NULL and using is.null() instead of using missing()

# Prefer "cols" over "select" for compat with tidyr::pivot_longer
if (!missing(cols)) {

Check warning on line 83 in R/data_to_long.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_long.R,line=83,col=7,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
select <- substitute(cols)
cols <- .select_nse(
select,
Expand All @@ -100,7 +91,7 @@
verbose = FALSE
)
} else {
if (!missing(select) || !is.null(select)) {

Check warning on line 94 in R/data_to_long.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_long.R,line=94,col=5,[unnecessary_nesting_linter] Simplify this condition by using 'else if' instead of 'else { if.
cols <- .select_nse(
select,
data,
Expand Down Expand Up @@ -205,7 +196,7 @@
header = FALSE
)
names(tmp) <- paste0("V", seq_len(ncol(tmp)))
tmp[tmp == ""] <- NA

Check warning on line 199 in R/data_to_long.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_long.R,line=199,col=11,[nzchar_linter] Use !nzchar(x) instead of x == "". Note that unlike nzchar(), EQ coerces to character, so you'll have to use as.character() if x is a factor. Whenever missing data is possible, please take care to use nzchar(., keepNA = TRUE); nzchar(NA) is TRUE by default.

stacked_data$ind <- NULL
stacked_data <- cbind(tmp, stacked_data)
Expand Down
26 changes: 1 addition & 25 deletions R/data_to_wide.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#' missing values in the new columns created.
#' @param verbose Toggle warnings.
#' @param ... Not used for now.
#' @param colnames_from Deprecated. Use `names_from` instead.
#' @param rows_from Deprecated. Use `id_cols` instead.
#' @param sep Deprecated. Use `names_sep` instead.
#'
#' @return If a tibble was provided as input, `reshape_wider()` also returns a
#' tibble. Otherwise, it returns a data frame.
Expand Down Expand Up @@ -93,29 +90,8 @@
names_glue = NULL,
values_fill = NULL,
verbose = TRUE,
...,
colnames_from,
rows_from,
sep) {
if (!missing(colnames_from)) {
.is_deprecated("colnames_from", "names_from")
if (is.null(names_from)) {
names_from <- colnames_from
}
}
if (!missing(rows_from)) {
.is_deprecated("rows_from", "id_cols")
...) {
if (is.null(id_cols)) {
id_cols <- rows_from
}
}
if (!missing(sep)) {
.is_deprecated("sep", "names_sep")
if (is.null(names_sep)) {
names_sep <- sep
}
}
if (is.null(id_cols)) {
id_cols <- setdiff(names(data), c(names_from, values_from))
}

Expand Down Expand Up @@ -218,26 +194,26 @@
if (!is.null(values_fill)) {
if (length(values_fill) == 1L) {
if (is.numeric(new_data[[values_from]])) {
if (!is.numeric(values_fill)) {

Check warning on line 197 in R/data_to_wide.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_wide.R,line=197,col=13,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
insight::format_error(paste0("`values_fill` must be of type numeric."))
} else {
new_data <- convert_na_to(new_data, replace_num = values_fill)
}
} else if (is.character(new_data[[values_from]])) {
if (!is.character(values_fill)) {

Check warning on line 203 in R/data_to_wide.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_wide.R,line=203,col=13,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
insight::format_error(paste0("`values_fill` must be of type character."))
} else {
new_data <- convert_na_to(new_data, replace_char = values_fill)
}
} else if (is.factor(new_data[[values_from]])) {
if (!is.factor(values_fill)) {

Check warning on line 209 in R/data_to_wide.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_wide.R,line=209,col=13,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
insight::format_error(paste0("`values_fill` must be of type factor."))
} else {
new_data <- convert_na_to(new_data, replace_fac = values_fill)
}
}
} else {
if (verbose) {

Check warning on line 216 in R/data_to_wide.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/data_to_wide.R,line=216,col=7,[unnecessary_nesting_linter] Simplify this condition by using 'else if' instead of 'else { if.
insight::format_error("`values_fill` must be of length 1.")
}
}
Expand Down
3 changes: 0 additions & 3 deletions man/data_partition.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions man/data_to_long.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions man/data_to_wide.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading