Learn R Programming

eeptools (version 0.1)

remove_stars: Function to replace a "*" in redcated data with an NA in 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

remove_stars(x)

Arguments

x
a vector of data that should be numeric but contains "*" characters forcing R to read it as character

Value

  • Returns a vector of the same length as the input vector that is numeric without "*" characters.

Examples

Run this code
a<-c(1,5,3,6,"*",2,5,"*","*")
b<-remove_stars(a)
is.numeric(b)

Run the code above in your browser using DataLab