1

This is my second day using R can anyone kindly tell me how to make a new column showing day of the week from an existing column which contains the dates.

my dates are in the format %d/%m/%y

I have used the following but it only shows for one day, I want it to show the whole column of dates

discount$day_of_week <-wday(as.Date('16-08-2012','%d-%m-%Y'), label=TRUE)

Can someone please kindly assist me?

lmo
  • 37,904
  • 9
  • 56
  • 69
AFC
  • 7
  • 2

1 Answers1

0

example of what you might want:

df <- data.frame(id = 1:5, date = seq(Sys.Date(), length.out = 5, by = 1))
df$day_name <-weekdays(df$date)
df
#   id       date day_name
# 1  1 2017-09-28 Thursday
# 2  2 2017-09-29   Friday
# 3  3 2017-09-30 Saturday
# 4  4 2017-10-01   Sunday
# 5  5 2017-10-02   Monday
minem
  • 3,640
  • 2
  • 15
  • 29