I have a column in a dataframe that contains the day number ( 0 through 6, 0=Sunday, 1=Monday, etc) and I need to convert that to the day name. How can I do this?
Sample data:
df <- data.frame(day_number=0:6)
Simple way with dplyr.
library(dplyr)
df <- data.frame(day_number=0:6)
df$day_number <- recode(df$day_number, 
       "0"="Sunday",
       "1"="Monday",
       "2"="Tuesday",
       "3"="Wednesday",
       "4"="Thursday",
       "5"="Friday",
       "6"="Saturday")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With