Learn R Programming

str2str (version 1.0.0)

is.Date: Test for a Date object

Description

is.Date returns whether an object is a Date object (aka has class = "Date").

Usage

is.Date(x)

Value

TRUE is x has class "Date" and FALSE if x does not have class "Date".

Arguments

x

an object.

Examples

Run this code
date <- as.Date("2021-05-24", format = "%Y-%m-%d") # as.Date.character
is.Date(date)
class(date) <- append(class(date), "extra_class")
is.Date(date) # classes other than Date are allowed
is.Date(list(date)) # returns FALSE

Run the code above in your browser using DataLab