Possible Duplicate:
Find the day of a week in R
I have a data for days like 11-01-2011 etc. But I want to add the data corresponding the date as Monday, Tuesday etc. Is there any R package that contains the information of the dates with days?
Method 2: Using strftime() function. In this method of converting the date of the week, the user needs to call strftime() function which is an in-built function and pass the respected parameters into it, and then in return, the function will give the weekdays of the given date to the user.
You can simply use weekdays(df$date) to extract the day of the week from the date. Only make sure the column is of type Date or convert using as. Date() .
For example, if your character dates are currently in the format “DD/MM/YYYY”, like “24/04/1968”, then you would use format = "%d/%m/%Y" to convert the values into dates.
The DAY function takes just one argument, the date from which you want to extract the day. In the example, the formula is: = DAY ( B5 ) B5 contains a date value for January 5, 2016. The DAY function returns the number 5 representing the day...
weekdays(as.Date('16-08-2012','%d-%m-%Y')) [1] "Thursday"
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