更新时间:2023-02-26 16:32:43
重建数据:
dat <- read.table(text="
date time numbers
01-02-2010 14:57 5
01-02-2010 23:23 7
02-02-2010 05:05 3
02-02-2010 10:23 11", header=TRUE)
现在使用as.POSIXct()
和paste()
将日期和时间组合为POSIX日期.您需要使用?strptime
中定义的符号来指定格式.另请参阅?DateTimeClasses
了解更多信息
Now use as.POSIXct()
and paste()
to combine your date and time into a POSIX date. You need to specify the format, using the symbols defined in ?strptime
. Also see ?DateTimeClasses
for more information
dat$newdate <- with(dat, as.POSIXct(paste(date, time), format="%m-%d-%Y %H:%M"))
plot(numbers ~ newdate, data=dat, type="b", col="blue")