Learn R Programming

bazar (version 1.0.11)

as.na: Transform values to NA

Description

These methods transform values to NA for different classes of objects.

Usage

as.na(x, ...)

# S3 method for default as.na(x, ...)

# S3 method for data.frame as.na(x, ...)

# S3 method for list as.na(x, ...)

Arguments

x

The object at stake.

...

Additional arguments (unused).

Value

An object of the same class as x; the attributes of x are passed unchanged to the result.

Examples

Run this code
# NOT RUN {
x <- c("a", "b", "c")
as.na(x)
class(as.na(x)) # still a character

x <- factor(LETTERS)
as.na(x)        # levels are kept
class(as.na(x)) # still a factor

x <- data.frame(x = 1:3, y = 2:4)
as.na(x)
dim(as.na(x))

x <- matrix(1:6, 2, 3)
attr(x, "today") <- Sys.Date()
as.na(x)        # attributes are kept

# }

Run the code above in your browser using DataLab