How to Change Integer to Date Class in R (Example Code)

This tutorial explains how to convert an integer to the Date class in R programming.

Creation of Example Data

my_integer <- 20230210                          # Create integer object
my_integer                                      # Display example integer
# [1] 20230210

Example: Change Integer to Date Class Using as.Date() & as.character() Functions

my_date <- as.Date(as.character(my_integer),    # Convert integer to date
                   format = "%Y%m%d")
my_date                                         # Display date object
# [1] "2023-02-10"

Related Articles & Further Resources

In the following, you can find some further resources on topics such as dates, variables, numeric values, and data conversion.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed