cleanNumbers: Strip all non-numeric characters from string formated test...

View source: R/cleanNumbers.R

cleanNumbersR Documentation

Strip all non-numeric characters from string formated test scores.

Description

Remove non-numeric characters from otherwise numeric standardized test scores.

Usage

cleanNumbers(c)

Arguments

c

A character vector of potentially numeric values.

Details

Remove or replace non-numeric characters that sometimes occur in otherwise numeric standardized test scores. Several characters are handled specially. These four characters "<>+*" are simply removed. The letter "K" is replaced with "0" (zero). All other non-numeric characters are removed. A count of each type of character removed or replaced is printed to the console.

cleanNumbers() calls helper functions scrubc() and swapc() to do its work.

Advantages over parse_number are that it provides explicit alerts as to what characters are being removed or replaced and in what quantity. Useful in cases where you are working with unfamiliar data (e.g., client data, or found data).

Value

A character vector

Author(s)

Dave Braze davebraze@gmail.com

See Also

parse_number scrubc()

Examples

c <- c("<K.1", "k.8", "2.5", "_4.3", "6.4", "12.9+", "9.2", "10.1", ">12.9")
cleanNumbers(c)


davebraze/FDButils documentation built on Feb. 24, 2023, 12:14 a.m.