I had read previous post but I cannot obtain that I want. I need to obtain a serie with 16 intervals by day (least the first and last day, in these cases the intervals start/end with the first/last observation). I would like that the observed variables are located in the corresponding inteval and NA otherwise.
My data look as follows: [Ya and Yb are the observed variables]
mdyhms Ya Yb
Mar-27-2009 19:56:47 25 58.25
Mar-27-2009 20:38:59 9 81.25
Mar-28-2009 08:00:30 9 88.75
Mar-28-2009 09:26:29 0 89.25
Mar-28-2009 11:57:01 8.5 74.25
Mar-28-2009 12:19:10 7.5 71.00
Mar-28-2009 14:17:05 1.5 70.00
Mar-28-2009 15:13:14 NA NA
Mar-28-2009 17:09:53 4 85.50
Mar-28-2009 18:37:24 0 86.00
Mar-28-2009 19:19:23 0 50.50
Mar-28-2009 20:45:50 0 36.25
Mar-29-2009 08:44:16 4.5 34.50
Mar-29-2009 10:35:12 8.5 39.50
Mar-29-2009 11:09:13 3.67 69.00
Mar-29-2009 12:40:07 0 54.25
Mar-29-2009 14:31:48 5.33 35.75
Mar-29-2009 16:19:27 6.33 71.75
Mar-29-2009 16:43:20 7.5 64.75
Mar-29-2009 18:37:42 8 83.75
Mar-29-2009 20:01:26 6.17 93.75
Mar-29-2009 20:43:53 NA NA
Mar-30-2009 08:42:05 12.67 88.50
Mar-30-2009 09:52:57 4.33 75.50
Mar-30-2009 12:01:32 1.83 70.75
Mar-30-2009 12:19:40 NA NA
Mar-30-2009 14:23:37 3.83 86.75
Mar-30-2009 16:00:59 37.33 80.25
Mar-30-2009 17:19:28 10.17 77.75
Mar-30-2009 17:49:12 9.83 73.00
Mar-30-2009 20:06:00 11.17 76.75
Mar-30-2009 21:40:35 20.33 68.25
Mar-31-2009 08:11:12 18.33 69.75
Mar-31-2009 09:51:29 14.5 65.50
Mar-31-2009 11:10:41 NA NA
Mar-31-2009 13:27:09 NA NA
Mar-31-2009 13:44:35 NA NA
Mar-31-2009 16:01:23 NA NA
Mar-31-2009 16:56:14 NA NA
Mar-31-2009 18:27:28 NA NA
Mar-31-2009 19:17:46 NA NA
Mar-31-2009 21:12:22 NA NA
Apr-01-2009 08:35:24 2.33 60.25
Apr-01-2009 09:24:49 1.33 71.50
Apr-01-2009 11:28:34 5.67 62.00
Apr-01-2009 13:31:48 NA NA
Apr-01-2009 14:52:18 NA NA
Apr-01-2009 15:11:44 1.5 71.50
Apr-01-2009 17:00:53 3.17 84.00
Thanks!
Presuming your dataframe is called "Data", I'd use xts package. They're a whole lot easier to work with :
Then TimeSeries can be used subsequently. You can't use a normal ts, because you don't have a regular time series. No way on earth you can defend that the time intervals between your observations are equal.
EDIT :
In regard of your remarks in the comments, you can try the following :