decimal_places_df {scrutiny}R Documentation

Count decimal places in a data frame

Description

For every value in a column, decimal_places_df() counts its decimal places. By default, it operates on all columns that are coercible to numeric.

Usage

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

Arguments

data

Data frame.

cols

Select columns from data using tidyselect. Default is everything(), but restricted by check_numeric_like.

check_numeric_like

Logical. If TRUE (the default), the function only operates on numeric columns and other columns coercible to numeric, as determined by is_numeric_like().

sep

Substring that separates the mantissa from the integer part. Default is "\\.", which renders a decimal point.

Value

Data frame. The values of the selected columns are replaced by the numbers of their decimal places.

See Also

Wrapped functions: decimal_places(), dplyr::across().

Examples

# Coerce all columns to string:
iris <- iris %>%
  tibble::as_tibble() %>%
  dplyr::mutate(across(everything(), as.character))

# The function will operate on all
# numeric-like columns but not on `"Species"`:
iris %>%
  decimal_places_df()

# Operate on some select columns only
# (from among the numeric-like columns):
iris %>%
  decimal_places_df(cols = starts_with("Sepal"))

[Package scrutiny version 0.4.0 Index]