1

我有带有相应时间戳值的运动数据(x,y)坐标,我需要在 R 中绘制它。gvisMotionChart()和其他googleVis产品似乎不接受时间戳值。有关可用于随时间可视化此运动数据的相关 R 包的任何想法?样本数据如下:

timestamp                    x    y
Feb 17, 2013 8:33:24 PM.000  724 414
Feb 17, 2013 8:34:24 PM.000  398 769
Feb 17, 2013 8:43:27 PM.000  398 769
Feb 17, 2013 8:44:15 PM.000  637 1083

非常感谢您的帮助!

4

1 回答 1

1

尝试这个:

DF <- read.table(text="timestamp; x; y
Feb 17, 2013 8:33:24 PM.000; 724; 414
Feb 17, 2013 8:34:24 PM.000; 398; 769
Feb 17, 2013 8:43:27 PM.000; 398; 769
Feb 17, 2013 8:44:15 PM.000; 637; 1083",
header=TRUE,sep=";",stringsAsFactors=FALSE)

DF$timestamp <- as.numeric(strptime(DF$timestamp,
                                    "%b %d, %Y %I:%M:%S %p.000",tz="GMT"))
DF$timestamp <- DF$timestamp-min(DF$timestamp)
DF$ID <- 1


library(googleVis)
M1 <- gvisMotionChart(DF, idvar="ID", timevar="timestamp",xvar="x", yvar="y")
plot(M1)
于 2013-03-22T10:09:45.123 回答