Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将中的chr时间转换为R中的实际时间_R_Datetime Conversion - Fatal编程技术网

将中的chr时间转换为R中的实际时间

将中的chr时间转换为R中的实际时间,r,datetime-conversion,R,Datetime Conversion,所以我试着把一个F1圈时间转换成一个时间,我可以把它画成一个直方图 这就是我试过的。但是没有成功 lapTimes <- lapTimes %>% mutate(Time = ms(Time)) format(as.POSIXct(lapTimes$time, tz = ""), format = "%M:%S.%OS") lapTimes%变异(时间=ms(时间)) 格式(如.POSIXct(lapTimes$time,tz=“”),格式=

所以我试着把一个F1圈时间转换成一个时间,我可以把它画成一个直方图

这就是我试过的。但是没有成功

lapTimes <- lapTimes %>% mutate(Time = ms(Time))
format(as.POSIXct(lapTimes$time, tz = ""), format = "%M:%S.%OS")
lapTimes%变异(时间=ms(时间))
格式(如.POSIXct(lapTimes$time,tz=“”),格式=“%M:%S.%OS”)
时间看起来总是像1:11.111,先是分钟,然后是秒,然后是毫秒。 如果有人有主意,我会非常感激


提前谢谢!:D

因为您没有提供示例数据,所以我假设它存储为字符

laptime <- "1:11.111"
> as.POSIXlt.character(laptime, format = "%M:%S.%OS", tz = 'GMT')
[1] "2021-01-14 00:01:11 GMT"

# compute time difference from dates
laptime <- "1:11.111"
t2 <- as.POSIXlt.character(laptime, format = "%M:%S.%OS", tz = 'GMT')
t1 <- as.Date(t2)

> difftime(t2, t1)
Time difference of 1.183333 mins
laptime为.POSIXlt.character(laptime,format=“%M:%S.%OS”,tz='GMT')
[1] “2021-01-14 00:01:11格林威治标准时间”
#计算日期的时差

laptime如前所述,我假设您的数据如下:

laptime <- c("1:11.111", "2:02.2222")
as.difftime(laptime, format = "%M:%S.%OS")
#Time differences in mins
#[1] 1.183333 2.033333