I have a data table, which I have various dates and a "value" with which I need to plot. The values are delivered in a so-called "Delivery Hour" and a "Delivery Interval". An example is below;
I can join a new colum to the right of my table, popultaed (in the first instance) with NAs using
data.table["TIME"]<-NA
This new column (shown below) needs to be populated in each row by the time of day that "value" was delivered, in excel I convert this via the function
=TIME(DELIVERY_HOUR-1, 30*(DELIVERY_INTERVAL-1),0)
So for example, with DELIVERY_HOUR =7 and DELIVERY_INTERVAL=2 this is 06:30.
I'd like to write a function that populates the TIME column row by row, here is my syntax for the function "TIME":
TIME function(x){ time<-(DELIVERY_HOUR-1):(30*(DELIVERY_INTERVAL-1)) result<-paste(time,format="%H%M") return(result) }
I am unsure how to ensure that corresponding row entries are picked and placed into the row entry for TIME.
Any help on this matter would be greatly appreciated.