I use R and have a data table with 3 columns:
unixtime | average by hour| 15 seconds value
The data contains several days of a year and all hours of those days. In 1 hour I have 1 value for "average by hour" which is at the top row of this hour. Further, there are 240 values for "15 seconds value". I created a for loop which takes hours to solve the problem, but would solve it.
for (i in 2:nrow(merge_demand)){
if (is.na(merge_demand[i,2])) {
merge_demand[i,2] = merge_demand[i-1,2]
}
}
Is there a more efficient way to just fill those 239 missing values of "average by hour" with the one existing value depending on this hour on this day? In total I have 1682761 rows.
I am kind of new to data tables so thanks for helping me out!