Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting date to a day of week in R [duplicate]

Tags:

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?

like image 662
Ikuyasu Avatar asked Aug 16 '12 04:08

Ikuyasu


People also ask

How do you convert a date into a day of the week in R?

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.

How do I extract days in R?

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() .

How do I convert a date in R?

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.

How do you convert days 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...


1 Answers

weekdays(as.Date('16-08-2012','%d-%m-%Y')) [1] "Thursday" 
like image 131
Roland Avatar answered Sep 25 '22 01:09

Roland