Convert Date to Weekday in R (Example)

This article shows how to convert a date object to the corresponding day of the week in the R programming language.

Example Data

We create an example vector with the as.Date function:

my_dates <- as.Date(c("2023-02-15", "2018-05-01", "1974-01-10"))  # Create vector of dates

Convert Dates to Days of the Week in R

We can convert our example dates to the corresponding days of the week with the weekdays function:

weekdays(my_dates)                                                # Convert dates to weekdays
# "Wednesday"   "Tuesday"   "Thursday"

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