如果我是你,我就只創建一個datetime列:
mydf$datetimes <- strptime(paste(mydf$dates, mydf$times), format = '%d.%m.%Y %H:%M')
現在mydf
樣子:
> mydf
dates times value datetimes
1 07.07.2016 22:00 3.00 2016-07-07 22:00:00
2 07.07.2016 23:00 3.00 2016-07-07 23:00:00
3 08.07.2016 00:00 3.00 2016-07-08 00:00:00
4 08.07.2016 01:00 3.00 2016-07-08 01:00:00
5 08.07.2016 02:00 3.00 2016-07-08 02:00:00
我用作輸入的數據:
mydf <- structure(list(dates = c("07.07.2016", "07.07.2016", "08.07.2016", "08.07.2016", "08.07.2016"),
times = c("22:00", "23:00", "00:00", "01:00", "02:00"),
value = c("3.00", "3.00", "3.00", "3.00", "3.00")),
.Names = c("dates", "times", "value"), class = "data.frame", row.names = c(NA, -5L))
嗨。我們不是免費的代碼寫作服務。請解釋你已經嘗試了什麼,你遇到了什麼問題,並提出一個確切的問題**。沒有問題,沒有機會得到答案。 –
我知道這不是一個免費的寫作服務。我不知道如何「找到並替換」「。」在日期數據中,以及如何將「00:」添加到hor數據中 – NUForever
您還沒有問過任何問題。你需要展示一個嘗試。問題是以「?」結尾的句子;它也需要成爲一個確切的問題。 –