Как я могу получить правильную дату из первого столбца в моем коде?
test <- data.frame(posixdate = c("2013-05-01 00:59:00", "2013-05-01 01:59:00", "2013-05-01 02:59:00", "2013-05-01 03:59:00"))
test$posixdate <- as.POSIXct(test$posixdate, format="%Y-%m-%d %H:%M:%S" )
test$date <- as.Date(test$posixdate)
Приведенный выше код приводит к:
posixdate date
1 2013-05-01 00:59:00 2013-04-30
2 2013-05-01 01:59:00 2013-04-30
3 2013-05-01 02:59:00 2013-05-01
4 2013-05-01 03:59:00 2013-05-01
Первые две даты неверны. Что я сделал не так?
Если as.Date()
— неправильная функция, как я могу получить дату (без часов, минут, секунд) в качестве альтернативы?
test$posixdate <- as.POSIXct(test$posixdate, tz = "GMT") ; as.Date(test$posixdate, tz = "GMT")
- person David Arenburg   schedule 23.03.2015as.Date
игнорирует. Просто сделайtest$posixdate <- as.POSIXct(test$posixdate, tz = "CET") ; as.Date(test$posixdate, tz = "CET")
- person David Arenburg   schedule 23.03.2015as.Date
— UTC. Читать?as.Date
- person David Arenburg   schedule 23.03.2015