DFna.to.empty: Data Frame NA to Empty

Description Usage Arguments Value Examples

View source: R/natoempty.R

Description

Converts all NA's certain columns of a data.frame to empty values

Usage

1
DFna.to.empty(x, coltypes = "all")

Arguments

x

A data.frame

coltypes

Character vector with the types of columns to affect. Default is "all", which includes logical, integer, double, complex, character, raw, and factor.

Value

A data.frame with the same dimensions and names as x. Columns whose types were specified in coltypes will be converted to character (except factors, which stay factor).

Examples

1
2
3
4
5
6
7
8
V1 = c(LETTERS[1:8], NA, NA)
V2 = c(NA, 1:8, NA)
V3 = factor(c(rep(c("A","B"), times = 4),NA, NA))
ex1 = data.frame(V1 = V1, V2 = V2, V3 = V3, stringsAsFactors = F)
DFna.to.empty(ex1)
DFna.to.empty(ex1, coltypes = "character")
DFna.to.empty(ex1, coltypes = c("character", "factor"))
DFna.to.empty(ex1, coltypes = c("character", "integer"))

debarros/dbTools documentation built on Sept. 18, 2020, 10:51 a.m.