用ggplot2绘制时间(HMS)

时间:2017-08-09 12:05:19

标签: r ggplot2 lubridate

我试图绘制正在运行的会话我想制作一个ggplot: x =距离(2.2KM,5KM,10KM,12.8KM,Ziel) Y =时间(HMS)

我有以下数据:

'data.frame':   16333 obs. of  6 variables:
 $ Numéro  : chr  "6526" "5427" "6528" "6529" ...
 $ X2.2km  : chr  "00:10:47.4" "00:08:58.2" "00:11:10.4" "00:09:27.3" ...
 $ X5km    : chr  "00:26:05.0" "00:21:46.1" "00:27:13.5" "00:22:35.3" ...
 $ X10km   : chr  "00:56:30.1" "00:45:59.3" "00:58:53.1" "00:47:51.7" ...
 $ X12.8km : chr  "01:14:24.7" "00:59:50.7" "01:17:35.0" "01:01:42.6" ...
 $ Zielzeit: chr  "01:37:40.0" "01:16:38.1" "01:41:53.0" "01:19:02.5" ...

下一步是使用库 reshape2 lubridate

中的融化功能
xx<-melt(xx,id="Numéro")
####Using lubridate ####
xx$value<-hms(xx$value)

我的问题在于,当我尝试绘制简单的图形时,我收到以下消息

> ggplot(xx,aes(variable,value))+geom_point()
Error in x < range[1] : cannot compare Period to Duration:
 coerce with 'as.numeric' first.
> ggplot(xx,aes(variable,value))+geom_line()
Error in x < range[1] : cannot compare Period to Duration:
 coerce with 'as.numeric' first.)

DATASET

  xx <- read.table(header=TRUE, text="   
       Numéro variable value
  1    6526   X2.2km 10M 47.4S
  2    5427   X2.2km  8M 58.2S
  3    6528   X2.2km 11M 10.4S
  4    6529   X2.2km  9M 27.3S
  5    6530   X2.2km  8M 29.3S")

感谢您的任何贡献。

0 个答案:

没有答案