naToZero {rrMisc} | R Documentation |
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 '-'.
naToZero(dataf, substit_numeric = TRUE, substit_character = FALSE, ...)
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 |
utility function for treating NAs
corresponding data.frame or vector with substituted NAs
Roland Rapold
(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)