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
-
- Signal: around 9am,
-
- Signal: around 11:30am,
-
- Signal: around 2pm,
-
- Signal: around 4:30pm,
-
- Signal: around 7pm,
-
- 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.
So here is the data: Original Data: structure(c(1559399495, 1559410907, 1559417625, 1559459908, 1559469538, 1559478830, 1559486650, 1559495990, 1559504661, 1559554718, 1559563310, 1559572971, 1559583383, 1559590366, 1559632394, 1559640716, 1559649675, 1559658794, 1559668671, 1559676814, 1559720350, 1559736095, 1559745212, 1559756054, 1559763779, 1559804530, 1559813489, 1559823971, 1559832774, 1559840465), class = c("POSIXct", "POSIXt"), tzone = "")
Desired Data: structure(c(NA, NA, NA, 1559399495, 1559410907, 1559417625, 1559459908, 1559469538, 1559478830, 1559486650, 1559495990, 1559504661, NA, 1559554718, 1559563310, 1559572971, 1559583383, 1559590366, 1559632394, 1559640716, 1559649675, 1559658794, 1559668671, 1559676814, 1559720350, NA, 1559736095, 1559745212, 1559756054, 1559763779), class = c("POSIXct", "POSIXt"), tzone = "")