naToZero {rrMisc}R Documentation

Substitution of NAs in data.frame or vector

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

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

        (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)

[Package rrMisc version 0.48 Index]