set_empty: Convert NAs to empty strings ("")

Description Usage Arguments Value Examples

View source: R/short_generic.R

Description

This can be useful when exporting a dataframe to a csv or excel format. It gets rid of the printed NA values in the output.

Usage

1

Arguments

x

a character vector

Value

A vector x of strings with NAs converted to an empty string ("")

Examples

1
2
3
4
5
6
7
8
# Set NA values in a vector to empty strings
fish_na = c("STHD", NA, "CHUM", "CHIN")
fish_missing = set_empty(fish_na)

# Set NA values in an entire dataframe to empty strings
fish_na = tibble::tibble(fish_day = c("Mon", NA_character_, "Wed", "Thur"),
                         fish_sp = c("STHD", NA_character_, "CHUM", "CHIN"))
fish_na[] = lapply(fish_na, set_empty)

arestrom/remisc documentation built on July 16, 2020, 8:48 a.m.