我希望可视化来自加速度传感器的数据。我有一个包含四列的数据框:时间(PosiXlt),AccX,AccY,AccZ(全部为数字)和大约3300万行。这是我的文件的负责人:
"time" "AccX.in.G" "AccY.in.G" "AccZ.in.G"
2015-06-24 04:00:00.092 -0.789 0.516 -0.374
2015-06-24 04:00:00.102 -0.782 0.52 -0.374
2015-06-24 04:00:00.112 -0.786 0.52 -0.371
2015-06-24 04:00:00.121 -0.786 0.516 -0.374
2015-06-24 04:00:00.131 -0.782 0.52 -0.371
2015-06-24 04:00:00.141 -0.782 0.52 -0.371
我希望将时间作为x轴,其他三个值作为线。我试着用ggplot绘图:
library(ggplot2)
library(reshape2)
Molten <- melt(MSR46, id.vars = "time")
ggplot(Molten, aes(x=time, y= value, group = variable)) + geom_line()
我得到的错误是
Aesthetics must either be length one, or the same length as the dataProblems:time
我检查了所有变量的长度,它们都是一样的。
因此,我不知道自己做错了什么。 我确信它很简单,但我只是不明白。有人可以帮帮我吗? 感谢
这是我文件的
dput(head(MSR46,10)):
"","time","AccX.in.G","AccY.in.G","AccZ.in.G"
"2",2015-06-24 04:00:00.092,-0.789,0.516,-0.374
"3",2015-06-24 04:00:00.102,-0.782,0.52,-0.374
"4",2015-06-24 04:00:00.112,-0.786,0.52,-0.371
"5",2015-06-24 04:00:00.121,-0.786,0.516,-0.374
"6",2015-06-24 04:00:00.131,-0.782,0.52,-0.371
"7",2015-06-24 04:00:00.141,-0.782,0.52,-0.371
"8",2015-06-24 04:00:00.151,-0.782,0.52,-0.378
"9",2015-06-24 04:00:00.161,-0.786,0.52,-0.374
"10",2015-06-24 04:00:00.171,-0.782,0.52,-0.374
"11",2015-06-24 04:00:00.181,-0.782,0.52,-0.371