as.na: Transform values to NA

Description Usage Arguments Value Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as.na(x, ...)

## Default S3 method:
as.na(x, ...)

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

## S3 method for class '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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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

bazar documentation built on May 2, 2019, 7:02 a.m.