0

I am trying to get the date part of a date-time POSIXt object in R I get a number instead.

Here is my data:

    y <- "2017-01-03 19:59:00"

Using following code:

    as.Date(as.POSIXct(y))

I get this number: 17169. I am in Eastern Time Zone (UTC-05:00) and have checked to make sure y is a POSIXt class. I am out of options and any help is appreciated.

Noel Bahdy
  • 29
  • 4
Fatima
  • 55
  • 6

1 Answers1

0

Your code worked fine in my system, have a look here :

enter image description here

Ayush Nigam
  • 364
  • 2
  • 8
  • That is weird. It worked fine on my machine previously as well. I though maybe some packages have been updated that I am not aware of and it does not work properly anymore. – Fatima Apr 04 '18 at 18:54
  • well. I figured it out. I was using the conversion in an ifelse function and that was the bug with ifelse. as I switched to if-else the problem is resolved. Thanks everyone – Fatima Apr 04 '18 at 18:59