remove_char: A function to replace an arbitrary character like a "*" in...

Description Usage Arguments Value Note Author(s) Examples

View source: R/remove_char.R

Description

Redacted education data files often have a "*" character. When importing into R this is a problem, which this function solves in a simple step by replacing "*" with NA, and then converting the vector to numeric.

Usage

1
remove_char(x, char)

Arguments

x

a vector of data that should be numeric but contains characters indicating redaction forcing R to read it as character

char

the character string that should be removed from the vector.

Value

Returns a vector of the same length as the input vector that is numeric with NAs in place of the character.

Note

Future versions could be modified to accommodate other indicators of redacted data.

Author(s)

Jared E. Knowles

Examples

1
2
3
a <- c(1, 5, 3, 6, "*", 2, 5, "*", "*")
b <- remove_char(a, "*")
as.numeric(b)

eeptools documentation built on May 3, 2020, 1:05 a.m.