I have a matrix with one column containing data (one sample per second) and another column with the timestamp in seconds. There is some seconds where the data doesn't change from the last one, and because of this doesn't appear on the vector. I wanted to apply a function, such as a simple mean, to time intervals (30 secs, for example). But for this I have to count with the missing seconds. What's the best way to do this?
- Create first a matrix with the repeated elements (I would also like to have the correct timestamps for the missing seconds included - the hardest part) and only then calculate means;
or
- Use a cycle (the worst way, I suppose) to calculate mean while inserting missing samples;
Thanks in advance!
ps.: OR is it possible to apply functions to the data identifying and automatically introducing (by repeating) the missing data?