TPP13.csv is what I get from the original TPP13.xlsx, then I read it:
TPP13<-read.csv("TPP13.csv")
Since the first column contains all the timestamps like "19/11/2020 17:00:00" but in different formats, so I use dmy_hms() and dmy_hm() to transform them respectively.
loops2<-dim(TPP13["TimeStamp1"])[1]
for (i in 1:loops1){
TPP13["TimeStamp1"][i,]<-dmy_hms(TPP13["TimeStamp1"][i,])
}
for (j in loops1+1:loops2){
TPP13["TimeStamp1"][j,]<-dmy_hm(TPP13["TimeStamp1"][j,])
}
Then, they are stored in the first column as a seconds format like "1605805200". After that I use as.numeric() and as_datatime() to turn these content to the correct datatime format.
TPP13["TimeStamp1"][1,]<-as.numeric(TPP13["TimeStamp1"][1,])
TPP13["TimeStamp1"][1,]<-as_datetime(as.numeric(TPP13["TimeStamp1"][1,]))
TPP13["TimeStamp1"][1,]
class(TPP13["TimeStamp1"][1,])
However, I find that I failed. TPP13["TimeStamp1"][1,] is still a second format and the class of it is still "character". I do not why I can not change the class of this value.