[R] Fill in missing times in a timeseries with NA
lglew
l.glew at soton.ac.uk
Wed Oct 27 14:57:28 CEST 2010
Hi,
I have a irregularly spaced time series dataset, which reads in from a .csv.
I need to convert this to a regularly spaced time series by filling in
missing rows of data with NAs.
So my data, called NtuMot, looks like this (I've removed some of the
additional rows for simplicity)....
ELEID date_time height slope
1 2009-06-24 00:00:00 150 4.0
1 2009-06-24 01:00:00 175 4.0
1 2009-06-24 02:00:00 180 2.3
1 2009-06-24 03:00:00 200 1.0
1 2009-06-24 06:00:00 201 1.0
1 2009-06-24 07:00:00 202 0.0
1 2009-06-24 08:00:00 202 0.0
1 2009-06-24 09:00:00 202 0.0
1 2009-06-24 10:00:00 202 0.0
I need to end up with this:
ELEID date_time height slope
1 2009-06-24 00:00:00 150 4.0
1 2009-06-24 01:00:00 175 4.0
1 2009-06-24 02:00:00 180 2.3
1 2009-06-24 03:00:00 200 1.0
1 2009-06-24 04:00:00 NA NA
1 2009-06-24 05:00:00 NA NA
1 2009-06-24 06:00:00 201 1.0
1 2009-06-24 07:00:00 202 0.0
1 2009-06-24 08:00:00 202 0.0
1 2009-06-24 09:00:00 202 0.0
1 2009-06-24 10:00:00 202 0.0
Any ideas much appreciated!
Thanks,
Louise
--
View this message in context: http://r.789695.n4.nabble.com/Fill-in-missing-times-in-a-timeseries-with-NA-tp3015391p3015391.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list