remove.erroneous.characters {DTwrappers2}R Documentation

remove.erroneous.characters

Description

This function attempts to convert a character vector to a numeric or complex vector, replacing erroneous values based on a specified threshold.

Usage

remove.erroneous.characters(
  x,
  threshold.for.numeric = 0.8,
  variable.should.be = "numeric",
  value.for.missing = NULL,
  ...
)

Arguments

x

A character vector of values that should be a numeric vector but was coerced to a character due to a small number of entries.

threshold.for.numeric

A value between 0 and 1 specifying the maximum proportion of x that does not "look" numeric. If threshold.for.numeric = 0.1, then no more than 10 percentage of the values in x can be values that do not "look" numeric.

variable.should.be

A character string specifying the target variable type ("numeric" or "complex"). Defaults to "numeric".

value.for.missing

The value to replace missing or erroneous entries with. Defaults to NA_real_ for numeric and NA_complex_ for complex.

...

Additional arguments .

Value

A numeric or complex vector with erroneous entries replaced, or the original character vector if the proportion of erroneous values exceeds the threshold.


[Package DTwrappers2 version 0.0.3 Index]