0

I have a set of data like this:

"2004-11-17 23:07:28 UTC" "2002-09-01 00:29:52 UTC" "2002-08-31 18:44:09 UTC" "2002-08-23 20:43:51 UTC"

Now i want the day of that date. I made:

Weekday <- c("mon", "tue", "Wed", "thu", "fri", "Sat","Sun")[as.POSIXlt(junit20$tstamp,tz="Etc/UTC")$wday]

But I dont get all days. Sunday is not in the dates at all eventhought it should be.

 [1] "Wed" "Sat" "fri"

What went wrong?

R newbie
  • 59
  • 5
  • Did you try `weekdays` function? `weekdays(x)` where `x` is your data. – Ronak Shah May 07 '20 at 08:38
  • I used weekdays already, but i want to work with as.POSIXlt to understand the way of working of r – R newbie May 07 '20 at 08:41
  • 1
    If you want to work with `POXIXlt`, a good place to start is reading the help text. `wday` has zero-based numbering; "`wday`: 0--6 day of the week, starting on Sunday." – Henrik May 07 '20 at 08:41
  • Read that thats why i startet with sun in my vector. I think there is a mistake in my thinking. – R newbie May 07 '20 at 08:48
  • `Weekday <- c("sun","mon", "tue", "wed", "thu", "fri", "sat")[as.POSIXlt(junit20$tstamp,tz="UTC")$wday + 1]` – Ronak Shah May 07 '20 at 08:55

0 Answers0