[Maturing]

na_as() returns a NA value with the same he same class and attributes of an R object.

This function was made to facilitate assigning NAs dynamically.

na_as(x)

# S3 method for class 'logical'
na_as(x)

# S3 method for class 'character'
na_as(x)

# S3 method for class 'integer'
na_as(x)

# S3 method for class 'numeric'
na_as(x)

# S3 method for class 'Duration'
na_as(x)

# S3 method for class 'Period'
na_as(x)

# S3 method for class 'difftime'
na_as(x)

# S3 method for class 'hms'
na_as(x)

# S3 method for class 'Date'
na_as(x)

# S3 method for class 'hms'
na_as(x)

# S3 method for class 'POSIXct'
na_as(x)

# S3 method for class 'POSIXlt'
na_as(x)

# S3 method for class 'Interval'
na_as(x)

Arguments

x

An atomic vector, provided that na_as() has a method for it.

Value

A NA value with the same class and attributes of x.

Examples

na_as(TRUE)
#> [1] NA
#> [1] NA # Expected
class(na_as(TRUE))
#> [1] "logical"
#> [1] "logical" # Expected

na_as(as.Date("2020-01-01"))
#> [1] NA
#> [1] NA # Expected
class(na_as(as.Date("2020-01-01")))
#> [1] "Date"
#> [1] "Date"  # Expected