I want to visualize data from an acceleration sensor. I have a data frame with four columns: time (PosiXlt), AccX, AccY, AccZ (all as numeric) and around 33 million rows. Here is the head of my file:
"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
I want to have a plot with the time as x-axis and the other three values as lines. I tried plotting with ggplot:
library(ggplot2)
library(reshape2)
Molten <- melt(MSR46, id.vars = "time")
ggplot(Molten, aes(x=time, y= value, group = variable)) + geom_line()
The error I'm getting is
Aesthetics must either be length one, or the same length as the dataProblems:time
I checked the length of all variables and they are all the same.
I therefore don't know what I'm doing wrong. I'm sure its simple but I just don't get it.
Can someone please help me? Thanks
here the
dput(head(MSR46,10))of my file:
"","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