convert_blank2NA: Convert all columns with blank data to NA

View source: R/convert.R

convert_blank2NAR Documentation

Convert all columns with blank data to NA

Description

convert_blank2NA converts a column of with blank ("") to NA. Be certain to check column data types afterwards, as dates and factors may be affected. Alternative: use related tidyverse verbs that can achieve a similar effect in perhaps a few more steps. To improve the speed of conversion between dates and characters, a default format is provided. For large data-sets, the data copy can be substantial and modifying the data in-place may be prefereable (uses data.table package)

Usage

convert_blank2NA(data, target = "", skip_dates = FALSE, modify_inplace = FALSE)

Arguments

data

Data object.

target

Replace all "" by default. Can replace with vector (e.g. c('', ' '))

skip_dates

Logical; exclude date columns from operation.

modify_inplace

Logical; uses data.table formats to reduce copies.

Value

Dataset with NA instead of blank ("") cells.

Examples

blankData <- data.frame(x = c(1, "", 2), y = c("", "Cool Stuff", "More Stuff"))
convert_blank2NA(blankData)


al-obrien/farrago documentation built on April 14, 2023, 6:20 p.m.