Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201919

Automatic fill in of missing dates in R for irregular datestamps

$
0
0

I have multiple time series datasets to analyze. In order to analyze I have to do preprocessing. One troublesome task is to identify irregualar missing rows and insert rows of NAs.

So far, I did this with:

new <- rep(NA, length(dati))
dati <- InsertRow(dati, NewRow=new, RowNum = 1)

Has anyone an idea how I could neatly insert those missing values without visually identifying those rows? I made some research, but only found solutions for irregualr missing rows for continous time date (e.g. 00:01 00:02 00:03...). The problem is, that my datestamps (6 per day) are rather irregular regarding hour and minute

    1. Signal: around 9am,
    1. Signal: around 11:30am,
    1. Signal: around 2pm,
    1. Signal: around 4:30pm,
    1. Signal: around 7pm,
    1. Signal: around 9:30pm

The only fixed term is, that per day, there have to be 6 signals / rows in the described order, but some of them are missing. I added two pictures, demonstrating what data I have and what I need to get as a result.

Original data:

original data

Desired data:

desired data


Viewing all articles
Browse latest Browse all 201919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>