naToZero: Substitution of NAs in data.frame or vector

Description Usage Arguments Details Value Author(s) Examples

View source: R/modify.R

Description

Substitution of NAs in a data.frame or a vector. NAs in numeric fields (integer, numeric) are substituted by 0, NAs in caracter fields are substituted by '-'.

Usage

1
naToZero(dataf, substit_numeric = TRUE, substit_character = FALSE, ...)

Arguments

dataf

data.frame or vector

substit_numeric

shall numeric fields (integer, numerical) be substituted?

substit_character

shall character fields be substituted?

...

arguments passed to further functions

Details

utility function for treating NAs

Value

corresponding data.frame or vector with substituted NAs

Author(s)

Roland Rapold

Examples

1
2
3
4
5
6
7
8
9
        (x <- c(pi, NA, 4.000000, 5.000000, 5, 6, 5, 6))
        naToZero(x)
        naToZero(x, substit_numeric=TRUE)
        naToZero(x, substit_numeric=FALSE)

        (x <- c("pi", NA, "4.000000", "5.000000", "5", "6", "5", "6"))
        naToZero(x)
        naToZero(x, substit_character=TRUE)
        naToZero(x, substit_character=FALSE)

rrMisc documentation built on June 25, 2021, 3 a.m.