na_if_string: Convert character elements in a data frame to NA

View source: R/na_if_string.R

na_if_stringR Documentation

Convert character elements in a data frame to NA

Description

In all character columns in data any elements matching any of na_strings are replaced with NA.

Usage

na_if_string(data, na_strings = c(""))

Arguments

data

A data frame.

na_strings

Character vector of strings to convert to missing values.

Value

A modified version of data with the same rows and columns.

Examples

df <- tibble::tibble(x1 = c("a", "", "1"),
                 x2 = c("-", "", "b"),
                 x3 = 1:3)
na_if_string(df, c("-", "", "1"))

jedwards24/edwards documentation built on Sept. 2, 2023, 8:16 a.m.