R 将日期和因子组合在一起,形成POSIXct日期时间,并拆分为列

R 将日期和因子组合在一起,形成POSIXct日期时间,并拆分为列,r,R,我有一个POSIXct对象,我只想将该对象的日期与存储在factor对象中的时间组合起来。代码如下: originalDate<- as.POSIXct("2014-10-27 13:39:01.885") time<- factor("13:30:00.994") class(time) time #I'd like to combine the date from "originalDate" and the time from "time" #so is o

我有一个POSIXct对象,我只想将该对象的日期与存储在factor对象中的时间组合起来。代码如下:

 originalDate<- as.POSIXct("2014-10-27 13:39:01.885")

 time<- factor("13:30:00.994")
 class(time)
 time

 #I'd like to combine the date from "originalDate" and the time from "time" 
  #so is of the type POSIXct and is --> 2014-10-27 13:30:00.994
originalDate可能


temp真棒。你知道如何从输出中提取小时、分钟、秒和毫秒吗?是的,但是你想用它们做什么?例如,您的新期望输出是什么?期望输出是小时=13分钟=30秒=0,毫秒=994,数字类型
temp <- paste(as.Date(doriginalDate), time)
temp
## [1] "2014-10-27 13:30:00.994"
as.numeric(strsplit(format(as.POSIXct(temp), "%H:%M:%OS3"), ":|\\.")[[1]])
## [1]  13  30   0 993