This is a sample of my data frame:
I UserID | Day_of_week | hour | min
#1 1 1 0 0
#2 1 1 0 30
#3 1 1 1 0
#4 1 1 1 30
#5 1 1 2 0
#6 1 1 2 30
... ... ... ... ...
#10 1 2 0 0
#11 1 2 0 30
#12 1 2 1 0
#13 1 2 1 30
... ... ... ... ...
The column Day_of_week goes from 1 to 7 where:
2 = Monday, 3 = Tuesday .... 6 = Friday
and 7 and 1 are Saturday and Sunday respectively.
I want to change in the column of Day_of_Week by the names of week. Something like this:
I UserID | Day_of_week | hour | min
#1 1 Sunday 0 0
#2 1 Sunday 0 30
#3 1 Sunday 1 0
... ... ... ... ...
#10 1 Monday 0 0
#11 1 Monday 0 30
#12 1 Monday 1 0
#13 1 Monday 1 30
... ... ... ... ...
c("Sunday","Monday",...,"Saturday")[x$Day_of_week]
? – r2evansweekdays
to generate a vector to subset:df$Day_of_week <- weekdays(as.Date('1970-01-01') + 2 + 1:7)[df$Day_of_week]
or more directly,weekdays(as.Date('1970-01-01') + 2 + df$Day_of_week)
– alistaire