Learn R Programming

relevance (version 2.1)

formatNA: Print NA values by a Desired Code

Description

Recodes the NA entries in output by a desired code like " ."

Usage

formatNA(x, na.print = " .", digits = getOption("digits"), ...)

Value

Should mimik the value of format

Arguments

x

object to be printed, usually a numeric vector or data.frame

na.print

code to be used for NA values

digits

number of digits for formatting numeric values

...

other arguments to format

Author

Werner A. Stahel

Details

The na.encode argument of print only applies to character objects. formatNA does the same for numeric arguments.

See Also

Examples

Run this code
formatNA(c(1,NA,3))

dd <- data.frame(X=c(1,NA,3), Y=c(4,5, NA), g=factor(c("a",NA,"b")))
(rr <- formatNA(dd, na.print="???"))
str(rr)

Run the code above in your browser using DataLab