rmg_bad_alnum_ratio: Rule A: alphanumeric ratio

Description Usage Arguments Value Examples

View source: R/rmgarbage.R

Description

If a string's ratio of alphanumeric characters to total characters is less than 50%, the string is garbage. From https://github.com/foodoh/rmgarbage

Usage

1
rmg_bad_alnum_ratio(x, threshold = 0.5)

Arguments

x

a character vector

threshold

a value between 0 and 1 for the alphanumeric to puncutation ratio

Value

Logical

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
garbage_string_r1 <-
  paste0(stringi::stri_rand_strings(1, 2, pattern = "[a-zA-Z0-9]"),
        "14.9˜;tv˜;<F~~~~9er&é(er@@|^˜:..", # this is garbage
          collapse = "")

garbage_string_r2 <-
  stringi::stri_rand_strings(1, 10, pattern = "[a-zA-Z0-9]")

  rmg_bad_alnum_ratio(garbage_string_r1) # TRUE
  rmg_bad_alnum_ratio(garbage_string_r2) # FALSE

benmarwick/rmgarbage documentation built on April 19, 2020, 6:06 p.m.