[R] Filling in missing time samples with na.approx

Jason Edgecombe jason at rampaginggeek.com
Mon Nov 29 15:45:27 CET 2010


Hi Everyone,

I have a some data from a sports gps device like the following:

         time latitude longitude altitude  distance heartrate
1 1277648884 0.304048 -0.793819      260  0.000000        94
2 1277648885 0.304056 -0.793772      262  4.307615        95
3 1277648888 0.304060 -0.793696      263 11.262347        97
4 1277648894 0.304075 -0.793544      263 25.237911       103
5 1277648898 0.304085 -0.793455      263 33.322525       108
6 1277648902 0.304064 -0.793387      256 40.042988       115

As you can see, the samples have irregular holes in the time column. How 
can I fill in the missing samples using na.approx?

I've tried to creating a blank series with no gaps and combine them, but 
"merge" just adds columns and "rbind" compains about duplicate indexes.

P.S. My GPS still has holes in the data when I turn off "smart recording" :(

Thanks,
Jason



More information about the R-help mailing list