Given the following dataframe generated by the code:
> df = data.frame(day=c('Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun'),
+ value=c(2,4,1,2,3,4,1))
> df
day value
1 Mon 2
2 Tues 4
3 Wed 1
4 Thurs 2
5 Fri 3
6 Sat 4
7 Sun 1
I want to convert Mon
, ... , Sun
to 1
, ...7
respectively to reflect the indexing of the day of the week.
Is there an easier/more straightforward way of doing this instead of using a defined function that checks the column value and converts the prefix to its assigned value?