Skip to content

Commit

Permalink
revert commits related to aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed May 18, 2024
1 parent 227e020 commit 6f7036d
Show file tree
Hide file tree
Showing 78 changed files with 282 additions and 360 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export(distribution_coef_var)
export(distribution_mode)
export(empty_columns)
export(empty_rows)
export(extract_column_names)
export(find_columns)
export(format_text)
export(get_columns)
export(kurtosis)
Expand Down
5 changes: 0 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ BREAKING CHANGES
* `means_by_group()`
* `rescale_weights()`

* Following aliases are deprecated and will be removed in a future release:

* `get_columns()`, use `data_select()` instead.
* `data_find()` and `find_columns()`, use `extract_column_names()` instead.

CHANGES

* `recode_into()` is more relaxed regarding checking the type of `NA` values.
Expand Down
2 changes: 1 addition & 1 deletion R/adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' re-added. This avoids the centering around 0 that happens by default
#' when regressing out another variable (see the examples below for a
#' visual representation of this).
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @inheritParams standardize
#'
#' @return A data frame comparable to `data`, with adjusted variables.
Expand Down
2 changes: 1 addition & 1 deletion R/assign_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' `x`, the right-hand side (RHS) the associated value label. Non-matching
#' labels are omitted.
#' @param ... Currently not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @inheritSection center Selection of variables - the `select` argument
#'
Expand Down
2 changes: 1 addition & 1 deletion R/categorize.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' variables are appended with new column names (using the defined suffix) to
#' the original data frame.
#' @param ... not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @inherit data_rename seealso
#'
Expand Down
2 changes: 1 addition & 1 deletion R/center.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' order, unless a named vector is given. In this case, names are matched
#' against the names of the selected variables.
#' @param ... Currently not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @inheritParams standardize
#'
#' @section Selection of variables - the `select` argument:
Expand Down
2 changes: 1 addition & 1 deletion R/convert_na_to.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ convert_na_to.character <- function(x, replacement = NULL, verbose = TRUE, ...)
#' @param replace_num Value to replace `NA` when variable is of type numeric.
#' @param replace_char Value to replace `NA` when variable is of type character.
#' @param replace_fac Value to replace `NA` when variable is of type factor.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @rdname convert_na_to
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/convert_to_na.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param drop_levels Logical, for factors, when specific levels are replaced
#' by `NA`, should unused levels be dropped?
#' @param ... Not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @return
#' `x`, where all values in `na` are converted to `NA`.
Expand Down
2 changes: 1 addition & 1 deletion R/data_addprefix.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @rdname data_rename
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @examples
#' # Add prefix / suffix to all columns
#' head(data_addprefix(iris, "NEW_"))
Expand Down
2 changes: 1 addition & 1 deletion R/data_codebook.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' @param line_padding For HTML tables, the distance (in pixel) between lines.
#' @param row_color For HTML tables, the fill color for odd rows.
#' @inheritParams standardize.data.frame
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @return A formatted data frame, summarizing the content of the data frame.
#' Returned columns include the column index of the variables in the original
Expand Down
2 changes: 1 addition & 1 deletion R/data_duplicated.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' values for that row, to help in the decision-making when
#' selecting which duplicates to keep.
#'
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @keywords duplicates
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/data_extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' @param verbose Toggle warnings.
#' @param ... For use by future methods.
#'
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @details `data_extract()` can be used to select multiple variables or pull a
#' single variable from a data frame. Thus, the return value is by default not
Expand Down
74 changes: 29 additions & 45 deletions R/extract_column_names.R → R/data_find.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#' @title Find or get columns in a data frame based on search patterns
#' @name extract_column_names
#' @name find_columns
#'
#' @description `extract_column_names()` returns column names from a data set that
#' match a certain search pattern, while `data_select()` returns the found data.
#' @description `find_columns()` returns column names from a data set that
#' match a certain search pattern, while `get_columns()` returns the found data.
#' `data_select()` is an alias for `get_columns()`, and `data_find()` is an alias
#' for `find_columns()`.
#'
#' @param data A data frame.
#' @param select Variables that will be included when performing the required
Expand Down Expand Up @@ -33,8 +35,8 @@
#' negation should not work as expected, use the `exclude` argument instead.
#'
#' If `NULL`, selects all columns. Patterns that found no matches are silently
#' ignored, e.g. `extract_column_names(iris, select = c("Species", "Test"))`
#' will just return `"Species"`.
#' ignored, e.g. `find_columns(iris, select = c("Species", "Test"))` will just
#' return `"Species"`.
#' @param exclude See `select`, however, column names matched by the pattern
#' from `exclude` will be excluded instead of selected. If `NULL` (the default),
#' excludes no columns.
Expand All @@ -56,10 +58,9 @@
#'
#' @return
#'
#' `extract_column_names()` returns a character vector with column names that
#' matched the pattern in `select` and `exclude`, or `NULL` if no matching
#' column name was found. `data_select()` returns a data frame with matching
#' columns.
#' `find_columns()` returns a character vector with column names that matched
#' the pattern in `select` and `exclude`, or `NULL` if no matching column name
#' was found. `get_columns()` returns a data frame with matching columns.
#'
#' @details
#'
Expand All @@ -68,12 +69,12 @@
#'
#' ```r
#' foo <- function(data, pattern) {
#' extract_column_names(data, select = starts_with(pattern))
#' find_columns(data, select = starts_with(pattern))
#' }
#' foo(iris, pattern = "Sep")
#'
#' foo2 <- function(data, pattern) {
#' extract_column_names(data, select = pattern)
#' find_columns(data, select = pattern)
#' }
#' foo2(iris, pattern = starts_with("Sep"))
#' ```
Expand All @@ -83,7 +84,7 @@
#' ```r
#' for (i in c("Sepal", "Sp")) {
#' head(iris) |>
#' extract_column_names(select = starts_with(i)) |>
#' find_columns(select = starts_with(i)) |>
#' print()
#' }
#' ```
Expand All @@ -93,7 +94,7 @@
#'
#' ```r
#' inner <- function(data, arg) {
#' extract_column_names(data, select = arg)
#' find_columns(data, select = arg)
#' }
#' outer <- function(data, arg) {
#' inner(data, starts_with(arg))
Expand All @@ -113,25 +114,25 @@
#'
#' @examples
#' # Find columns names by pattern
#' extract_column_names(iris, starts_with("Sepal"))
#' extract_column_names(iris, ends_with("Width"))
#' extract_column_names(iris, regex("\\."))
#' extract_column_names(iris, c("Petal.Width", "Sepal.Length"))
#' find_columns(iris, starts_with("Sepal"))
#' find_columns(iris, ends_with("Width"))
#' find_columns(iris, regex("\\."))
#' find_columns(iris, c("Petal.Width", "Sepal.Length"))
#'
#' # starts with "Sepal", but not allowed to end with "width"
#' extract_column_names(iris, starts_with("Sepal"), exclude = contains("Width"))
#' find_columns(iris, starts_with("Sepal"), exclude = contains("Width"))
#'
#' # find numeric with mean > 3.5
#' numeric_mean_35 <- function(x) is.numeric(x) && mean(x, na.rm = TRUE) > 3.5
#' extract_column_names(iris, numeric_mean_35)
#' find_columns(iris, numeric_mean_35)
#' @export
extract_column_names <- function(data,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...) {
find_columns <- function(data,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...) {
columns <- .select_nse(
select,
data,
Expand All @@ -154,23 +155,6 @@ extract_column_names <- function(data,
}


#' @rdname extract_column_names
#' @rdname find_columns
#' @export
data_find <- function(data,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...) {
insight::format_warning("Function `data_find()` is deprecated and will be removed in a future release. Please use `extract_column_names()` instead.") # nolint
extract_column_names(
data,
select = select,
exclude = exclude,
ignore_case = ignore_case,
regex = regex,
verbose = verbose,
...
)
}
data_find <- find_columns
2 changes: 1 addition & 1 deletion R/data_group.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' grouping information from a grouped data frame.
#'
#' @param data A data frame
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @return A grouped data frame, i.e. a data frame with additional information
#' about the grouping structure saved as attributes.
Expand Down
2 changes: 1 addition & 1 deletion R/data_peek.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @param width Maximum width of line length to display. If `NULL`, width will
#' be determined using `options()$width`.
#' @param ... not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @note To show only specific or a limited number of variables, use the
#' `select` argument, e.g. `select = 1:5` to show only the first five variables.
Expand Down
2 changes: 1 addition & 1 deletion R/data_relocate.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' character vector, indicating the name of the destination column, or a
#' numeric value, indicating the index number of the destination column.
#' If `-1`, will be added before or after the last column.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @inheritParams data_rename
#'
#' @inherit data_rename seealso
Expand Down
2 changes: 1 addition & 1 deletion R/data_remove.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @rdname data_relocate
#' @examples
#' # Remove columns
Expand Down
2 changes: 1 addition & 1 deletion R/data_replicate.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' provided in `expand` are removed from the data frame. If `FALSE` and `expand`
#' contains missing values, the function will throw an error.
#' @param ... Currently not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @return A dataframe with each row replicated as many times as defined in `expand`.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/data_rescale.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' (change the keying/scoring direction), or to expand a range.
#'
#' @inheritParams categorize
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @inheritParams standardize.data.frame
#'
#' @param to Numeric vector of length 2 giving the new range that the variable
Expand Down
2 changes: 1 addition & 1 deletion R/data_reverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' usually only makes sense when factor levels are numeric, not characters.
#' @param ... Arguments passed to or from other methods.
#' @inheritParams categorize
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @inheritSection center Selection of variables - the `select` argument
#'
Expand Down
25 changes: 4 additions & 21 deletions R/data_select.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @rdname extract_column_names
#' @rdname find_columns
#' @export
data_select <- function(data,
get_columns <- function(data,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
Expand Down Expand Up @@ -34,23 +34,6 @@ data_select <- function(data,
}


#' @rdname extract_column_names
#' @rdname find_columns
#' @export
get_columns <- function(data,
select = NULL,
exclude = NULL,
ignore_case = FALSE,
regex = FALSE,
verbose = TRUE,
...) {
insight::format_warning("Function `get_columns()` is deprecated and will be removed in a future release. Please use `data_select()` instead.") # nolint
data_select(
data,
select = select,
exclude = exclude,
ignore_case = ignore_case,
regex = regex,
verbose = verbose,
...
)
}
data_select <- get_columns
2 changes: 1 addition & 1 deletion R/data_separate.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#' @param convert_na Logical, if `TRUE`, character `"NA"` values are converted
#' into real `NA` values.
#' @param ... Currently not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @seealso [`data_unite()`]
#'
Expand Down
2 changes: 1 addition & 1 deletion R/data_tabulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' not `NULL`. Can be `"row"` (row percentages), `"column"` (column percentages)
#' or `"full"` (to calculate relative frequencies for the full table).
#' @param ... not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @section Crosstables:
#' If `by` is supplied, a crosstable is created. The crosstable includes `<NA>`
Expand Down
2 changes: 1 addition & 1 deletion R/data_to_long.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @param rows_to The name of the column that will contain the row names or row
#' numbers from the original data. If `NULL`, will be removed.
#' @param ... Currently not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#' @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.
Expand Down
2 changes: 1 addition & 1 deletion R/data_unique.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' @param keep The method to be used for duplicate selection, either "best"
#' (the default), "first", or "last".
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @return A data frame, containing only the chosen duplicates.
#' @seealso [data_duplicated()]
Expand Down
2 changes: 1 addition & 1 deletion R/data_unite.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' in the united values. If `FALSE`, missing values are represented as `"NA"`
#' in the united values.
#' @param ... Currently not used.
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @seealso [`data_separate()`]
#'
Expand Down
2 changes: 1 addition & 1 deletion R/describe_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' (based on [stats::IQR()], using `type = 6`).
#' @param verbose Toggle warnings and messages.
#' @inheritParams bayestestR::point_estimate
#' @inheritParams extract_column_names
#' @inheritParams find_columns
#'
#' @details If `x` is a data frame, only numeric variables are kept and will be
#' displayed in the summary.
Expand Down
Loading

0 comments on commit 6f7036d

Please sign in to comment.