as_na: Transform values to NA

Description Usage Arguments Value Examples

View source: R/as_na.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
as_na(x, ...)

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

paulponcet/bazar documentation built on July 15, 2019, 5:28 a.m.