I want convert the following the column of the dataframe in to 00:00:00 (HH:MM:SS)
and class of the output should be the "POSIXct" format
.
This is not an exact duplicate of as.POSIXct with datetimes including midnight because these times do not include midnight.
Here Column of the dataframe.
> gg
[1] "2018-01-16 10:29:00 IST" "2018-01-16 10:29:00 IST"
[3] "2018-01-16 10:29:00 IST" "2018-01-16 10:29:00 IST"
[5] "2018-01-16 10:29:00 IST" "2018-01-16 10:29:00 IST"
I tired the following code,it's not solve the my problem
paste(as.Date(gg, format="%Y-%m-%d"),"00:00:00")
[1] "2018-01-16 00:00:00" "2018-01-16 00:00:00" "2018-01-16 00:00:00"
[4] "2018-01-16 00:00:00" "2018-01-16 00:00:00" "2018-01-16 00:00:00"
And i need class of the output should be in "POSIXct" "POSIXt"
So i am applying the as.POSIXct
and here missing the 00:00:00
as.POSIXct(paste(as.Date(gg, format="%Y-%m-%d"),"00:00:00"))
[1] "2018-01-16 IST" "2018-01-16 IST" "2018-01-16 IST" "2018-01-16 IST"
[5] "2018-01-16 IST" "2018-01-16 IST"
Required format is
[1] "2018-01-16 00:00:00 IST" "2018-01-16 00:00:00 IST"
[3] "2018-01-16 00:00:00 IST" "2018-01-16 00:00:00 IST"
[5] "2018-01-16 00:00:00 IST" "2018-01-16 00:00:00 IST"
And class should be "POSIXct" "POSIXt"
Dataset
> dput(gg)
structure(c(1516078740, 1516078740, 1516078740, 1516078740, 1516078740,
1516078740), class = c("POSIXct", "POSIXt"), tzone = "")
Thank you.