I have a dataset (datatable) with three columns:
- date
- time
- price
The dataset is in one minute intervals and I need to convert this to fifteen minute intervals. To do this I want the average of the price per 15 rows. I need this in a new dataframe (of 15 times less rows than original) so I can copy/paste this in another dataset where there are already 15 minute intervals.
I tried to create a new list by getting the mean of every 15 rows with the below code:
means.price <- dt.Energy.prices[, mean(dt.Energy.prices$Lowest_price_downward), by=
(seq(nrow(dt.Energy.prices)) - 1) %/% 15]
I get a new dataset where all the means are NA. Means.price has around 70.000 obs. where original had around 1.05 million. It worked out to create a dataset which is 1/15 of original but the means are still missing.
Sometime the column price has an NA. So sometimes all 15 are NA, but sometimes 5 rows have a value where the other 10 have NA. If it are 15, I'm ok with output mean NA but when there are some values known, I hope there is a way to average the known values.