0

How can I convert the date into weekday in numeric form? Similar question here:Find the day of a week

When run on my computer, the out put look like this:

> weekdays.Date(as.Date("2016-12-31"))
[1] "星期六"

But I am designing a program that will be dispatched to people from all over the world.

Same code run on different computer might give different result:

> weekdays.Date(as.Date("2016-12-31"))
[1] "Saturday"

This makes the situation complicated if I need to consider putting a translation chunk in my code.

I wonder if there is a way that, when doing the conversion it returns weekdays in numbers. For instance, Monday is 1, Tuesday is 2 ..., Sunday is 7.

Community
  • 1
  • 1

1 Answers1

0

From strptime help...

format(as.Date("2017-03-12"),"%u")

Andrew Gustar
  • 17,295
  • 1
  • 22
  • 32