Having an issue reformatting Date to Weekday

Hi all, I am trying to reformat a column of dates in the format mm-dd-yyyy into a new column that spits out the weekday of the corresponding date, but I have been stuck for the last couple of hours. Is there any guidelines I can follow to help write the code?

Some of the code I have tried using are as follows;

mutate(daily_steps = as.Date(Date, format = "%A", abbreviate = FALSE))
This function runs, however, it is spitting out the correct weekday of the date.

The dataset I am using for my project is from this link FitBit Fitness Tracker Data | Kaggle
And the CSV file I am using is the dailySteps_merged.csv

Any tips would be greatly appreciated, thank you!

as.Date() returns date object, try to use as.character() which returns a character string:

> as.character(as.Date("04-20-2022", format = "%M-%d-%Y"), format = "%A")
[1] "środa"

which is Wednesday in my locales.

from help:

Value
The format and as.character methods return a character vector representing the date. NA dates are returned as NA_character_.

The as.Date methods return an object of class "Date".

Regards,
Grzegorz

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.