I have a some GPS data from my Garmin I’d like to graph time scaled. I found some example on the ‘net for using ggplot2 to do this, but have had issues with it – I believe i might need to reformat my datetime column, but couldn’t figure it out searching ‘net and looking at the ggplot2 source code. Any help much appreciated.
> library(ggplot2)
> x <- read.csv("tst.csv",header=TRUE,colClasses="character")
> head(x)
counter HeartRateBpm_AVG LastTimeStamp
1 1 102.25 9/3/2011 7:32
2 2 138.75 9/3/2011 7:33
3 3 138.75 9/3/2011 7:33
4 4 138.75 9/3/2011 7:33
5 5 138.75 9/3/2011 7:33
6 6 138.75 9/3/2011 7:34
> ggplot(data=x,aes(x=LastTimeStamp,y=HeartRateBpm_AVG)) + scale_x_date(format = "%S") + geom_line()
I do not believe you could have used that input process to get that data.frame. You only have one item in the “colClasses” vector. When I used your method, the result was not much different than if I had used
readLines. Your date-time column is not printing as though it made it in in a manner that could be converted without a format-spec. Try instead: