Changing days of the week into weekdays

I'm trying to convert days of the week into actual weekdays and I'm getting an error. Below is the code that I wrote followed by the error message:

weekly_steps<-daily_activity %>% 
mutate(weekday=weekdays(ActivityDay))
weekly_steps$weekday<- ordered(weekly_steps$weekday, levels= c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
weekly_sleep<- sleep_day %>% 
mutate(weekday=weekdays(ActivityDay))
weekly_sleep$weekday<- ordered(weekly_sleep$weekday, levels= c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
weekly_steps<-weekly_steps %>% 
group_by(weekday) %>% 
summarize(daily_steps=mean(TotalSteps))
head(weekly_steps)

Error in mutate():
:information_source: In argument: weekday = weekdays(ActivityDay).
Caused by error in UseMethod():
! no applicable method for 'weekdays' applied to an object of class "character"
Run rlang::last_trace() to see where the error occurred.
Error in mutate(., weekday = weekdays(ActivityDay)) :
Caused by error in UseMethod():
! no applicable method for 'weekdays' applied to an object of class "character"

Can someone please help me solve the error(s) in my code please.

The error says that ActivityDay is a character and the function weekdays does not have a method for characters. My guess is that you need to convert ActivityDay into a date value, possibly with as.Date() or asPOSIXct(). If that does not help you, please explain what is in the column ActivityDay.

This doesn't work:

> weekdays("2025-03-20")
Error in UseMethod("weekdays") : 
  no applicable method for 'weekdays' applied to an object of class "character"

Use this

> weekdays(as.Date("2025-03-20"))
[1] "Thursday"
1 Like