-
Notifications
You must be signed in to change notification settings - Fork 3
/
getNZGxpMeta.R
28 lines (28 loc) · 969 Bytes
/
getNZGxpMeta.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#' \code{getNZGxpMeta} generates metadata for a given dt
#'
#' Creates various summaries for reporting.
#'
#' @param dt the data.table to report
#' @return dt a data.table of info
#' @import data.table
#' @author Ben Anderson, \email{b.anderson@@soton.ac.uk} (original)
#' @export
#' @family data
#' @family grid
#' @family gxp
#' @family NZ
#'
getNZGxpMeta <- function(dt){
dt <- dt[, month := lubridate::month(rDate)]
dt <- dt[, year := lubridate::year(rDate)]
testDT <- dt[, .(nObs = .N,
sumMWh = sum(as.numeric(kWh/1000), na.rm = TRUE),
meanMWh = mean(as.numeric(kWh/1000), na.rm = TRUE),
nGenTypes = uniqueN(GENERATION_TYPE),
nTraders = uniqueN(TRADER),
dateFrom = min(rDate),
dateTo = max(rDate),
nDays = uniqueN(rDate)), keyby = .(month,
year)]
return(testDT)
}