Learn R Programming

scrutiny (version 1.0.0)

decimal_places_df: Count decimal places in a data frame

Description

[Deprecated]

decimal_places_df() is deprecated because it replaces the values by their counts, while the tests need both. Use decimal_places() in dplyr::mutate() instead, as in mutate(digits_x = decimal_places(x)).

decimal_places_df() replaces every value in the selected columns by its number of decimal places. By default, it operates on all columns coercible to numeric.

Usage

decimal_places_df(
  data,
  cols = everything(),
  check_numeric_like = TRUE,
  sep = "."
)

Value

Data frame with the selected columns replaced by their counts of decimal places.

Arguments

data

Data frame.

cols

Columns to operate on, selected with tidyselect. Default is everything(), restricted by check_numeric_like.

check_numeric_like

Logical. If TRUE (the default), only columns that is_numeric_like() accepts are processed. A column that isn't numeric-like gets a warning if cols is given and selects it, or if it is processed anyway, unless it is empty.

sep

String. The separator between the integer part and the decimal places, matched literally. Default is ".".

See Also

decimal_places().

Examples

Run this code
iris <- iris |>
  tibble::as_tibble() |>
  dplyr::mutate(across(everything(), as.character))

# All numeric-like columns, silently leaving out `Species`:
iris |>
  decimal_places_df()

# Selected columns only:
iris |>
  decimal_places_df(cols = starts_with("Sepal"))

Run the code above in your browser using DataLab